Skip to content

Commit b387ba4

Browse files
ndeloofglours
authored andcommitted
only load COMPOSE_* from $PWD/.env
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 7cd5699 commit b387ba4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

cmd/compose/compose.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ func setEnvWithDotEnv(opts ProjectOptions) error {
693693
return nil
694694
}
695695
for k, v := range envFromFile {
696-
if _, ok := os.LookupEnv(k); !ok {
696+
if _, ok := os.LookupEnv(k); !ok && strings.HasPrefix(k, "COMPOSE_") {
697697
if err = os.Setenv(k, v); err != nil {
698698
return nil
699699
}

cmd/compose/run.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ func (options runOptions) apply(project *types.Project) (*types.Project, error)
120120
return project, nil
121121
}
122122

123-
func (options runOptions) getEnvironment() (types.Mapping, error) {
124-
environment := types.NewMappingWithEquals(options.environment).Resolve(os.LookupEnv).ToMapping()
123+
func (options runOptions) getEnvironment(resolve func(string) (string, bool)) (types.Mapping, error) {
124+
environment := types.NewMappingWithEquals(options.environment).Resolve(resolve).ToMapping()
125125
for _, file := range options.envFiles {
126126
f, err := os.Open(file)
127127
if err != nil {
@@ -289,7 +289,7 @@ func runRun(ctx context.Context, backend api.Service, project *types.Project, op
289289
buildForRun = &bo
290290
}
291291

292-
environment, err := options.getEnvironment()
292+
environment, err := options.getEnvironment(project.Environment.Resolve)
293293
if err != nil {
294294
return err
295295
}

0 commit comments

Comments
 (0)