From 45956c36fba5d50cc43312600dd848a2187dc0d8 Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Mon, 22 Nov 2021 19:47:32 +0100 Subject: [PATCH] introduce docker compose config --images Signed-off-by: Nicolas De Loof --- cmd/compose/convert.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/cmd/compose/convert.go b/cmd/compose/convert.go index 0ad85fa1..125331d6 100644 --- a/cmd/compose/convert.go +++ b/cmd/compose/convert.go @@ -48,6 +48,7 @@ type convertOptions struct { services bool volumes bool profiles bool + images bool hash string } @@ -85,6 +86,9 @@ func convertCommand(p *projectOptions, backend api.Service) *cobra.Command { if opts.profiles { return runProfiles(opts, args) } + if opts.images { + return runConfigImages(opts, args) + } return runConvert(ctx, backend, opts, args) }), @@ -100,6 +104,7 @@ func convertCommand(p *projectOptions, backend api.Service) *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.BoolVar(&opts.images, "images", false, "Print the image names, one per line.") flags.StringVar(&opts.hash, "hash", "", "Print the service config hash, one per line.") flags.StringVarP(&opts.Output, "output", "o", "", "Save to file (default to stdout)") @@ -215,3 +220,18 @@ func runProfiles(opts convertOptions, services []string) error { } return nil } + +func runConfigImages(opts convertOptions, services []string) error { + project, err := opts.toProject(services) + if err != nil { + return err + } + for _, s := range project.Services { + if s.Image != "" { + fmt.Println(s.Image) + } else { + fmt.Printf("%s_%s\n", project.Name, s.Name) + } + } + return nil +}