diff --git a/cmd/compose/convert.go b/cmd/compose/convert.go index 0ad85fa19..125331d6b 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 +}