aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-11-09 20:01:31 +0000
committerGitHub <noreply@github.com>2020-11-09 20:01:31 +0000
commit110a1d8f25c87739afe790ac2bc461937f17222a (patch)
tree2009b729aaf5f5ff7a0aef20e474f56847512108 /cmd
parent1491b20f089546eb4859df774964df3e2b31803d (diff)
parentf14cb5ef61e37d27bdde6dbc94b5bd910c2e8cf3 (diff)
downloadpodman-110a1d8f25c87739afe790ac2bc461937f17222a.tar.gz
podman-110a1d8f25c87739afe790ac2bc461937f17222a.tar.bz2
podman-110a1d8f25c87739afe790ac2bc461937f17222a.zip
Merge pull request #8276 from Luap99/search-json
Add support for podman search --format json
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/images/search.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/cmd/podman/images/search.go b/cmd/podman/images/search.go
index 774b39d3a..7de6a7316 100644
--- a/cmd/podman/images/search.go
+++ b/cmd/podman/images/search.go
@@ -1,6 +1,7 @@
package images
import (
+ "fmt"
"os"
"text/tabwriter"
"text/template"
@@ -81,7 +82,7 @@ func init() {
// searchFlags set the flags for the pull command.
func searchFlags(flags *pflag.FlagSet) {
flags.StringSliceVarP(&searchOptions.Filters, "filter", "f", []string{}, "Filter output based on conditions provided (default [])")
- flags.StringVar(&searchOptions.Format, "format", "", "Change the output format to a Go template")
+ flags.StringVar(&searchOptions.Format, "format", "", "Change the output format to JSON or a Go template")
flags.IntVar(&searchOptions.Limit, "limit", 0, "Limit the number of results")
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")
@@ -135,6 +136,13 @@ func imageSearch(cmd *cobra.Command, args []string) error {
return errors.Errorf("filters are not applicable to list tags result")
}
row = "{{.Name}}\t{{.Tag}}\n"
+ case report.IsJSON(searchOptions.Format):
+ prettyJSON, err := json.MarshalIndent(searchReport, "", " ")
+ if err != nil {
+ return err
+ }
+ fmt.Println(string(prettyJSON))
+ return nil
case cmd.Flags().Changed("format"):
renderHeaders = parse.HasTable(searchOptions.Format)
row = report.NormalizeFormat(searchOptions.Format)