From 25d536748013bccd204c30173871a96fd078b33d Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Tue, 30 Mar 2021 10:39:17 +0200 Subject: [PATCH] introduce config --profiles for parity with docker-compose Signed-off-by: Nicolas De Loof --- cli/cmd/compose/convert.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/cli/cmd/compose/convert.go b/cli/cmd/compose/convert.go index e8a1298f..63e5c36c 100644 --- a/cli/cmd/compose/convert.go +++ b/cli/cmd/compose/convert.go @@ -46,6 +46,7 @@ type convertOptions struct { noInterpolate bool services bool volumes bool + profiles bool hash string } @@ -76,6 +77,9 @@ func convertCommand(p *projectOptions) *cobra.Command { if opts.hash != "" { return runHash(opts) } + if opts.profiles { + return runProfiles(opts) + } return runConvert(cmd.Context(), opts, args) }, @@ -88,6 +92,7 @@ func convertCommand(p *projectOptions) *cobra.Command { flags.BoolVar(&opts.services, "services", false, "Print the service names, one per line.") flags.BoolVar(&opts.volumes, "volumes", false, "Print the volume names, one per line.") + flags.BoolVar(&opts.profiles, "profiles", false, "Print the profile names, one per line.") flags.StringVar(&opts.hash, "hash", "", "Print the service config hash, one per line.") // add flags for hidden backends @@ -189,3 +194,20 @@ func runHash(opts convertOptions) error { } return nil } + +func runProfiles(opts convertOptions) error { + profiles := map[string]struct{}{} + project, err := opts.toProject(nil) + if err != nil { + return err + } + for _, s := range project.Services { + for _, p := range s.Profiles { + profiles[p] = struct{}{} + } + } + for _, p := range profiles { + fmt.Println(p) + } + return nil +}