Skip to content

Commit

Permalink
Merge pull request #441 from ndeloof/include_env
Browse files Browse the repository at this point in the history
  • Loading branch information
ndeloof committed Aug 10, 2023
2 parents 339d49d + 8e131a4 commit acec34a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions loader/include.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"path/filepath"

"github.com/compose-spec/compose-go/dotenv"
interp "github.com/compose-spec/compose-go/interpolation"
"github.com/compose-spec/compose-go/types"
"github.com/pkg/errors"
)
Expand Down Expand Up @@ -74,11 +75,17 @@ func loadInclude(ctx context.Context, configDetails types.ConfigDetails, model *
return nil, err
}

imported, err := load(ctx, types.ConfigDetails{
config := types.ConfigDetails{
WorkingDir: r.ProjectDirectory,
ConfigFiles: types.ToConfigFiles(r.Path),
Environment: env,
}, loadOptions, loaded)
}
loadOptions.Interpolate = &interp.Options{
Substitute: options.Interpolate.Substitute,
LookupValue: config.LookupEnv,
TypeCastMapping: options.Interpolate.TypeCastMapping,
}
imported, err := load(ctx, config, loadOptions, loaded)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion loader/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2528,7 +2528,7 @@ services:
},
{
Name: "imported",
ContainerName: "imported",
ContainerName: "extends", // as defined by ./testdata/subdir/extra.env
Environment: types.MappingWithEquals{"SOURCE": strPtr("extends")},
EnvFile: types.StringList{
filepath.Join(workingDir, "testdata", "subdir", "extra.env"),
Expand Down

0 comments on commit acec34a

Please sign in to comment.