66import lombok .Getter ;
77import lombok .extern .slf4j .Slf4j ;
88import org .apache .commons .io .FileUtils ;
9+ import org .snakeyaml .engine .v2 .api .Load ;
10+ import org .snakeyaml .engine .v2 .api .LoadSettings ;
11+ import org .snakeyaml .engine .v2 .constructor .StandardConstructor ;
12+ import org .snakeyaml .engine .v2 .nodes .Node ;
13+ import org .snakeyaml .engine .v2 .nodes .Tag ;
914import org .testcontainers .images .ParsedDockerfile ;
10- import org .yaml .snakeyaml .DumperOptions ;
11- import org .yaml .snakeyaml .LoaderOptions ;
12- import org .yaml .snakeyaml .Yaml ;
13- import org .yaml .snakeyaml .constructor .SafeConstructor ;
14- import org .yaml .snakeyaml .nodes .Node ;
15- import org .yaml .snakeyaml .nodes .Tag ;
16- import org .yaml .snakeyaml .representer .Representer ;
17- import org .yaml .snakeyaml .resolver .Resolver ;
1815
1916import java .io .File ;
2017import java .io .FileInputStream ;
@@ -42,12 +39,14 @@ class ParsedDockerComposeFile {
4239 private final Map <String , Set <String >> serviceNameToImageNames = new HashMap <>();
4340
4441 ParsedDockerComposeFile (File composeFile ) {
45- // The default is 50 and a big docker-compose.yml file can easily go above that number. 1,000 should give us some room
46- LoaderOptions options = new LoaderOptions ();
47- options .setMaxAliasesForCollections (1_000 );
48- DumperOptions dumperOptions = new DumperOptions ();
49-
50- SafeConstructor constructor = new SafeConstructor (options ) {
42+ LoadSettings loadSettings = LoadSettings
43+ .builder ()
44+ // The default is 50 and a big docker-compose.yml file can easily go above that number.
45+ // 1,000 should give us some room
46+ .setMaxAliasesForCollections (1_000 )
47+ .build ();
48+
49+ StandardConstructor constructor = new StandardConstructor (loadSettings ) {
5150 @ Override
5251 protected Object constructObject (Node node ) {
5352 if (node .getTag ().equals (new Tag ("!reset" ))) {
@@ -56,9 +55,9 @@ protected Object constructObject(Node node) {
5655 return super .constructObject (node );
5756 }
5857 };
59- Yaml yaml = new Yaml ( constructor , new Representer ( dumperOptions ), dumperOptions , options , new Resolver () );
58+ Load load = new Load ( loadSettings , constructor );
6059 try (FileInputStream fileInputStream = FileUtils .openInputStream (composeFile )) {
61- composeFileContent = yaml . load (fileInputStream );
60+ composeFileContent = ( Map < String , Object >) load . loadFromInputStream (fileInputStream );
6261 } catch (Exception e ) {
6362 throw new IllegalArgumentException ("Unable to parse YAML file from " + composeFile .getAbsolutePath (), e );
6463 }
0 commit comments