Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show output of podman image search --list-tags command #407

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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