diff --git a/mgradm/cmd/upgrade/podman/podman.go b/mgradm/cmd/upgrade/podman/podman.go index b73e3cfd8..0d2045b54 100644 --- a/mgradm/cmd/upgrade/podman/podman.go +++ b/mgradm/cmd/upgrade/podman/podman.go @@ -45,10 +45,8 @@ func NewCommand(globalFlags *types.GlobalFlags) *cobra.Command { if err := viper.Unmarshal(&flags); err != nil { log.Fatal().Err(err).Msg(L("failed to unmarshall configuration")) } - tags, _ := podman.ShowAvailableTag(globalFlags.Registry, flags.Image) - log.Info().Msgf(L("Available Tags for image: %s"), flags.Image.Name) - for _, value := range tags { - log.Info().Msgf(value) + if err := podman.ShowAvailableTag(globalFlags.Registry, flags.Image); err != nil { + log.Fatal().Err(err) } }, } diff --git a/shared/podman/images.go b/shared/podman/images.go index 6ee5e7d55..ec0a770da 100644 --- a/shared/podman/images.go +++ b/shared/podman/images.go @@ -218,20 +218,19 @@ func pullImage(authFile string, image string) error { } // ShowAvailableTag returns the list of available tag for a given image. -func ShowAvailableTag(registry string, image types.ImageFlags) ([]string, error) { +func ShowAvailableTag(registry string, image types.ImageFlags) error { log.Info().Msgf(L("Running podman image search --list-tags %s --format={{.Tag}}"), image.Name) name, err := utils.ComputeImage(registry, utils.DefaultTag, image) if err != nil { - return []string{}, err + return err } - out, err := utils.RunCmdOutput(zerolog.DebugLevel, "podman", "image", "search", "--list-tags", name, "--format={{.Tag}}") - if err != nil { - return []string{}, utils.Errorf(err, L("cannot find any tag for image %s"), image) + + if err := utils.RunCmdStdMapping(zerolog.DebugLevel, "podman", "image", "search", "--list-tags", name, "--format={{.Tag}}"); err != nil { + return utils.Errorf(err, L("cannot find any tag for image %s"), image) } - tags := strings.Split(string(out), "\n") - return tags, nil + return nil } // GetRunningImage given a container name, return the image name. diff --git a/uyuni-tools.changes.mbussolotto.list_auth b/uyuni-tools.changes.mbussolotto.list_auth new file mode 100644 index 000000000..3146301dc --- /dev/null +++ b/uyuni-tools.changes.mbussolotto.list_auth @@ -0,0 +1 @@ +- show output of podman image search --list-tags command