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

Commit 25d5367

Browse files
committed
introduce config --profiles for parity with docker-compose
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent ee4e85a commit 25d5367

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

cli/cmd/compose/convert.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ type convertOptions struct {
4646
noInterpolate bool
4747
services bool
4848
volumes bool
49+
profiles bool
4950
hash string
5051
}
5152

@@ -76,6 +77,9 @@ func convertCommand(p *projectOptions) *cobra.Command {
7677
if opts.hash != "" {
7778
return runHash(opts)
7879
}
80+
if opts.profiles {
81+
return runProfiles(opts)
82+
}
7983

8084
return runConvert(cmd.Context(), opts, args)
8185
},
@@ -88,6 +92,7 @@ func convertCommand(p *projectOptions) *cobra.Command {
8892

8993
flags.BoolVar(&opts.services, "services", false, "Print the service names, one per line.")
9094
flags.BoolVar(&opts.volumes, "volumes", false, "Print the volume names, one per line.")
95+
flags.BoolVar(&opts.profiles, "profiles", false, "Print the profile names, one per line.")
9196
flags.StringVar(&opts.hash, "hash", "", "Print the service config hash, one per line.")
9297

9398
// add flags for hidden backends
@@ -189,3 +194,20 @@ func runHash(opts convertOptions) error {
189194
}
190195
return nil
191196
}
197+
198+
func runProfiles(opts convertOptions) error {
199+
profiles := map[string]struct{}{}
200+
project, err := opts.toProject(nil)
201+
if err != nil {
202+
return err
203+
}
204+
for _, s := range project.Services {
205+
for _, p := range s.Profiles {
206+
profiles[p] = struct{}{}
207+
}
208+
}
209+
for _, p := range profiles {
210+
fmt.Println(p)
211+
}
212+
return nil
213+
}

0 commit comments

Comments
 (0)