Skip to content

Commit

Permalink
WithDefaultProfiles must read COMPOSE_PROFILES from project.Environment
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof committed May 30, 2024
1 parent 197e635 commit 7dfa54c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions cli/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,16 @@ func WithLoadOptions(loadOptions ...func(*loader.Options)) ProjectOptionsFn {

// WithDefaultProfiles uses the provided profiles (if any), and falls back to
// profiles specified via the COMPOSE_PROFILES environment variable otherwise.
func WithDefaultProfiles(profile ...string) ProjectOptionsFn {
if len(profile) == 0 {
for _, s := range strings.Split(os.Getenv(consts.ComposeProfiles), ",") {
profile = append(profile, strings.TrimSpace(s))
func WithDefaultProfiles(profiles ...string) ProjectOptionsFn {
return func(o *ProjectOptions) error {
if len(profiles) == 0 {
for _, s := range strings.Split(o.Environment[consts.ComposeProfiles], ",") {
profiles = append(profiles, strings.TrimSpace(s))
}
}

o.loadOptions = append(o.loadOptions, loader.WithProfiles(profiles))
return nil
}
return WithProfiles(profile)
}

// WithProfiles sets profiles to be activated
Expand Down

0 comments on commit 7dfa54c

Please sign in to comment.