use COMPOSE_PROFILES value only if no command line arg profiles used

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
Guillaume Lours 2022-10-10 13:53:39 +02:00
parent 386c3554e5
commit 533fc61634
1 changed files with 4 additions and 4 deletions

View File

@ -209,6 +209,10 @@ func (o *projectOptions) toProject(services []string, po ...cli.ProjectOptionsFn
project.Services[i] = s
}
if profiles, ok := options.Environment["COMPOSE_PROFILES"]; ok && len(o.Profiles) == 0 {
o.Profiles = append(o.Profiles, strings.Split(profiles, ",")...)
}
if len(services) > 0 {
s, err := project.GetServices(services...)
if err != nil {
@ -217,10 +221,6 @@ func (o *projectOptions) toProject(services []string, po ...cli.ProjectOptionsFn
o.Profiles = append(o.Profiles, s.GetProfiles()...)
}
if profiles, ok := options.Environment["COMPOSE_PROFILES"]; ok {
o.Profiles = append(o.Profiles, strings.Split(profiles, ",")...)
}
project.ApplyProfiles(o.Profiles)
project.WithoutUnnecessaryResources()