mirror of https://github.com/docker/compose.git
introduce config --profiles for parity with docker-compose
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
ee4e85ae1d
commit
25d5367480
|
@ -46,6 +46,7 @@ type convertOptions struct {
|
||||||
noInterpolate bool
|
noInterpolate bool
|
||||||
services bool
|
services bool
|
||||||
volumes bool
|
volumes bool
|
||||||
|
profiles bool
|
||||||
hash string
|
hash string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +77,9 @@ func convertCommand(p *projectOptions) *cobra.Command {
|
||||||
if opts.hash != "" {
|
if opts.hash != "" {
|
||||||
return runHash(opts)
|
return runHash(opts)
|
||||||
}
|
}
|
||||||
|
if opts.profiles {
|
||||||
|
return runProfiles(opts)
|
||||||
|
}
|
||||||
|
|
||||||
return runConvert(cmd.Context(), opts, args)
|
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.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.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.")
|
flags.StringVar(&opts.hash, "hash", "", "Print the service config hash, one per line.")
|
||||||
|
|
||||||
// add flags for hidden backends
|
// add flags for hidden backends
|
||||||
|
@ -189,3 +194,20 @@ func runHash(opts convertOptions) error {
|
||||||
}
|
}
|
||||||
return nil
|
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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue