Skip to content

Commit

Permalink
show output of podman image search --list-tags command
Browse files Browse the repository at this point in the history
  • Loading branch information
mbussolotto committed Jul 22, 2024
1 parent d3f890d commit 1e24343
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
6 changes: 2 additions & 4 deletions mgradm/cmd/upgrade/podman/podman.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
},
}
Expand Down
13 changes: 6 additions & 7 deletions shared/podman/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions uyuni-tools.changes.mbussolotto.list_auth
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- show output of podman image search --list-tags command

0 comments on commit 1e24343

Please sign in to comment.