summaryrefslogtreecommitdiff
path: root/cmd/podman/images/search.go
diff options
context:
space:
mode:
authorQi Wang <qiwan@redhat.com>2020-09-29 16:40:10 -0400
committerQi Wang <qiwan@redhat.com>2020-10-09 11:49:46 -0400
commit66798e993a1d3c111f15a85242cac1427c39f53e (patch)
treeead22c734350fa97d4fc1d611d1934be233f3c59 /cmd/podman/images/search.go
parent73488369586d387db0e4754fa56d5d0077a24940 (diff)
downloadpodman-66798e993a1d3c111f15a85242cac1427c39f53e.tar.gz
podman-66798e993a1d3c111f15a85242cac1427c39f53e.tar.bz2
podman-66798e993a1d3c111f15a85242cac1427c39f53e.zip
Search repository tags using --list-tags
For fix of BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1684263 Add --list-tags to podman search to return a table the repository tags. Signed-off-by: Qi Wang <qiwan@redhat.com>
Diffstat (limited to 'cmd/podman/images/search.go')
-rw-r--r--cmd/podman/images/search.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/cmd/podman/images/search.go b/cmd/podman/images/search.go
index b8f590585..8edd776ce 100644
--- a/cmd/podman/images/search.go
+++ b/cmd/podman/images/search.go
@@ -85,6 +85,7 @@ func searchFlags(flags *pflag.FlagSet) {
flags.BoolVar(&searchOptions.NoTrunc, "no-trunc", false, "Do not truncate the output")
flags.StringVar(&searchOptions.Authfile, "authfile", auth.GetDefaultAuthFile(), "Path of the authentication file. Use REGISTRY_AUTH_FILE environment variable to override")
flags.BoolVar(&searchOptions.TLSVerifyCLI, "tls-verify", true, "Require HTTPS and verify certificates when contacting registries")
+ flags.BoolVar(&searchOptions.ListTags, "list-tags", false, "List the tags of the input registry")
}
// imageSearch implements the command for searching images.
@@ -101,6 +102,10 @@ func imageSearch(cmd *cobra.Command, args []string) error {
return errors.Errorf("Limit %d is outside the range of [1, 100]", searchOptions.Limit)
}
+ if searchOptions.ListTags && len(searchOptions.Filters) != 0 {
+ return errors.Errorf("filters are not applicable to list tags result")
+ }
+
// TLS verification in c/image is controlled via a `types.OptionalBool`
// which allows for distinguishing among set-true, set-false, unspecified
// which is important to implement a sane way of dealing with defaults of
@@ -119,12 +124,19 @@ func imageSearch(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
+
if len(searchReport) == 0 {
return nil
}
hdrs := report.Headers(entities.ImageSearchReport{}, nil)
row := "{{.Index}}\t{{.Name}}\t{{.Description}}\t{{.Stars}}\t{{.Official}}\t{{.Automated}}\n"
+ if searchOptions.ListTags {
+ if len(searchOptions.Filters) != 0 {
+ return errors.Errorf("filters are not applicable to list tags result")
+ }
+ row = "{{.Name}}\t{{.Tag}}\n"
+ }
if cmd.Flags().Changed("format") {
row = report.NormalizeFormat(searchOptions.Format)
}