@@ -907,7 +907,8 @@ services:
907907 image: nginx
908908 env_file:
909909 - example1.env
910- - example2.env
910+ - path: example2.env
911+ required: false
911912`
912913 expectedEnvironmentMap := types.MappingWithEquals {
913914 "FOO" : strPtr ("foo_from_env_file" ),
@@ -925,14 +926,21 @@ services:
925926 options .ResolvePaths = false
926927 })
927928 assert .NilError (t , err )
928- assert .DeepEqual (t , configWithEnvFiles .Services ["web" ].EnvFile , types.StringList {"example1.env" ,
929- "example2.env" })
929+ assert .DeepEqual (t , configWithEnvFiles .Services ["web" ].EnvFiles , []types.EnvFile {
930+ {
931+ Path : "example1.env" ,
932+ Required : true ,
933+ },
934+ {
935+ Path : "example2.env" ,
936+ Required : false ,
937+ }})
930938 assert .DeepEqual (t , configWithEnvFiles .Services ["web" ].Environment , expectedEnvironmentMap )
931939
932940 // Custom behavior removes the `env_file` entries
933941 configWithoutEnvFiles , err := Load (configDetails , WithDiscardEnvFiles )
934942 assert .NilError (t , err )
935- assert .DeepEqual (t , configWithoutEnvFiles .Services ["web" ].EnvFile , types . StringList ( nil ) )
943+ assert .Equal (t , len ( configWithoutEnvFiles .Services ["web" ].EnvFiles ), 0 )
936944 assert .DeepEqual (t , configWithoutEnvFiles .Services ["web" ].Environment , expectedEnvironmentMap )
937945}
938946
@@ -1929,7 +1937,11 @@ func TestLoadWithExtends(t *testing.T) {
19291937 Environment : types.MappingWithEquals {
19301938 "SOURCE" : strPtr ("extends" ),
19311939 },
1932- EnvFile : []string {expectedEnvFilePath },
1940+ EnvFiles : []types.EnvFile {
1941+ {
1942+ Path : expectedEnvFilePath ,
1943+ Required : true ,
1944+ }},
19331945 Networks : map [string ]* types.ServiceNetworkConfig {"default" : nil },
19341946 Volumes : []types.ServiceVolumeConfig {{
19351947 Type : "bind" ,
@@ -2090,8 +2102,10 @@ func TestLoadServiceWithEnvFile(t *testing.T) {
20902102 },
20912103 Services : types.Services {
20922104 "test" : {
2093- Name : "test" ,
2094- EnvFile : []string {file .Name ()},
2105+ Name : "test" ,
2106+ EnvFiles : []types.EnvFile {
2107+ {Path : file .Name (), Required : true },
2108+ },
20952109 },
20962110 },
20972111 }
@@ -2450,8 +2464,11 @@ services:
24502464 Name : "imported" ,
24512465 ContainerName : "extends" , // as defined by ./testdata/subdir/extra.env
24522466 Environment : types.MappingWithEquals {"SOURCE" : strPtr ("extends" )},
2453- EnvFile : types.StringList {
2454- filepath .Join (workingDir , "testdata" , "subdir" , "extra.env" ),
2467+ EnvFiles : []types.EnvFile {
2468+ {
2469+ Path : filepath .Join (workingDir , "testdata" , "subdir" , "extra.env" ),
2470+ Required : true ,
2471+ },
24552472 },
24562473 Image : "nginx" ,
24572474 Volumes : []types.ServiceVolumeConfig {
@@ -2630,8 +2647,11 @@ services:
26302647 Name : "foo" ,
26312648 Image : "foo" ,
26322649 Environment : types.MappingWithEquals {"FOO" : strPtr ("BAR" )},
2633- EnvFile : types.StringList {
2634- filepath .Join (config .WorkingDir , "testdata" , "remote" , "env" ),
2650+ EnvFiles : []types.EnvFile {
2651+ {
2652+ Path : filepath .Join (config .WorkingDir , "testdata" , "remote" , "env" ),
2653+ Required : true ,
2654+ },
26352655 },
26362656 Volumes : []types.ServiceVolumeConfig {
26372657 {
0 commit comments