diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2020-06-19 15:30:32 +0200 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2020-06-19 15:30:32 +0200 |
commit | bba433ed926a8ba78e628e1a1d9861ac5ed35e54 (patch) | |
tree | 235c6ee0aabaf72d6099f580fd0dfdcb71777a56 /cmd/podman/images | |
parent | 5ec29f8d4e79500915ec79824d9eb21630205f3f (diff) | |
download | podman-bba433ed926a8ba78e628e1a1d9861ac5ed35e54.tar.gz podman-bba433ed926a8ba78e628e1a1d9861ac5ed35e54.tar.bz2 podman-bba433ed926a8ba78e628e1a1d9861ac5ed35e54.zip |
podman images --format json: pretty print
Pretty print the JSON output when listing images. We regressed on that
during v2 development. The indentation is now identical to the one of
Podman v1.9.3.
Fixes: #6687
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'cmd/podman/images')
-rw-r--r-- | cmd/podman/images/list.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/cmd/podman/images/list.go b/cmd/podman/images/list.go index 236ae15b4..4a9df5712 100644 --- a/cmd/podman/images/list.go +++ b/cmd/podman/images/list.go @@ -141,8 +141,12 @@ func writeJSON(imageS []*entities.ImageSummary) error { imgs = append(imgs, h) } - enc := json.NewEncoder(os.Stdout) - return enc.Encode(imgs) + prettyJSON, err := json.MarshalIndent(imgs, "", " ") + if err != nil { + return err + } + fmt.Println(string(prettyJSON)) + return nil } func writeTemplate(imageS []*entities.ImageSummary) error { |