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>
This commit is contained in:
Valentin Rothberg
2020-06-19 15:30:32 +02:00
parent 5ec29f8d4e
commit bba433ed92

View File

@ -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 {