Skip to content

Commit acec34a

Browse files
authored
Merge pull request #441 from ndeloof/include_env
2 parents 339d49d + 8e131a4 commit acec34a

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

loader/include.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"path/filepath"
2323

2424
"github.com/compose-spec/compose-go/dotenv"
25+
interp "github.com/compose-spec/compose-go/interpolation"
2526
"github.com/compose-spec/compose-go/types"
2627
"github.com/pkg/errors"
2728
)
@@ -74,11 +75,17 @@ func loadInclude(ctx context.Context, configDetails types.ConfigDetails, model *
7475
return nil, err
7576
}
7677

77-
imported, err := load(ctx, types.ConfigDetails{
78+
config := types.ConfigDetails{
7879
WorkingDir: r.ProjectDirectory,
7980
ConfigFiles: types.ToConfigFiles(r.Path),
8081
Environment: env,
81-
}, loadOptions, loaded)
82+
}
83+
loadOptions.Interpolate = &interp.Options{
84+
Substitute: options.Interpolate.Substitute,
85+
LookupValue: config.LookupEnv,
86+
TypeCastMapping: options.Interpolate.TypeCastMapping,
87+
}
88+
imported, err := load(ctx, config, loadOptions, loaded)
8289
if err != nil {
8390
return nil, err
8491
}

loader/loader_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2528,7 +2528,7 @@ services:
25282528
},
25292529
{
25302530
Name: "imported",
2531-
ContainerName: "imported",
2531+
ContainerName: "extends", // as defined by ./testdata/subdir/extra.env
25322532
Environment: types.MappingWithEquals{"SOURCE": strPtr("extends")},
25332533
EnvFile: types.StringList{
25342534
filepath.Join(workingDir, "testdata", "subdir", "extra.env"),

0 commit comments

Comments
 (0)