Skip to content

Commit 7dfa54c

Browse files
committed
WithDefaultProfiles must read COMPOSE_PROFILES from project.Environment
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 197e635 commit 7dfa54c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

cli/options.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,16 @@ func WithLoadOptions(loadOptions ...func(*loader.Options)) ProjectOptionsFn {
215215

216216
// WithDefaultProfiles uses the provided profiles (if any), and falls back to
217217
// profiles specified via the COMPOSE_PROFILES environment variable otherwise.
218-
func WithDefaultProfiles(profile ...string) ProjectOptionsFn {
219-
if len(profile) == 0 {
220-
for _, s := range strings.Split(os.Getenv(consts.ComposeProfiles), ",") {
221-
profile = append(profile, strings.TrimSpace(s))
218+
func WithDefaultProfiles(profiles ...string) ProjectOptionsFn {
219+
return func(o *ProjectOptions) error {
220+
if len(profiles) == 0 {
221+
for _, s := range strings.Split(o.Environment[consts.ComposeProfiles], ",") {
222+
profiles = append(profiles, strings.TrimSpace(s))
223+
}
222224
}
223-
225+
o.loadOptions = append(o.loadOptions, loader.WithProfiles(profiles))
226+
return nil
224227
}
225-
return WithProfiles(profile)
226228
}
227229

228230
// WithProfiles sets profiles to be activated

0 commit comments

Comments
 (0)