Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 8b245d9

Browse files
authored
Merge pull request #1525 from ulyssessouza/fix-profiles
Fix compose config --profiles
2 parents aaf662b + 6dbfc71 commit 8b245d9

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

cli/cmd/compose/compose.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,11 @@ func (o *projectOptions) toProject(services []string, po ...cli.ProjectOptionsFn
7777
return nil, err
7878
}
7979

80-
if len(services) != 0 {
81-
s, err := project.GetServices(services...)
82-
if err != nil {
83-
return nil, err
84-
}
85-
o.Profiles = append(o.Profiles, s.GetProfiles()...)
80+
s, err := project.GetServices(services...)
81+
if err != nil {
82+
return nil, err
8683
}
84+
o.Profiles = append(o.Profiles, s.GetProfiles()...)
8785

8886
if profiles, ok := options.Environment["COMPOSE_PROFILES"]; ok {
8987
o.Profiles = append(o.Profiles, strings.Split(profiles, ",")...)

cli/cmd/compose/convert.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func convertCommand(p *projectOptions) *cobra.Command {
7878
return runHash(opts)
7979
}
8080
if opts.profiles {
81-
return runProfiles(opts)
81+
return runProfiles(opts, args)
8282
}
8383

8484
return runConvert(cmd.Context(), opts, args)
@@ -195,19 +195,19 @@ func runHash(opts convertOptions) error {
195195
return nil
196196
}
197197

198-
func runProfiles(opts convertOptions) error {
199-
profiles := map[string]struct{}{}
200-
project, err := opts.toProject(nil)
198+
func runProfiles(opts convertOptions, services []string) error {
199+
profiles := map[string]interface{}{}
200+
_, err := opts.toProject(services)
201201
if err != nil {
202202
return err
203203
}
204-
for _, s := range project.Services {
205-
for _, p := range s.Profiles {
206-
profiles[p] = struct{}{}
204+
if opts.projectOptions != nil {
205+
for _, p := range opts.projectOptions.Profiles {
206+
profiles[p] = nil
207+
}
208+
for p := range profiles {
209+
fmt.Println(p)
207210
}
208-
}
209-
for _, p := range profiles {
210-
fmt.Println(p)
211211
}
212212
return nil
213213
}

0 commit comments

Comments
 (0)