summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2020-04-07 08:27:10 -0500
committerBrent Baude <bbaude@redhat.com>2020-04-07 08:27:10 -0500
commit90884ac2d2394df67241410415f74b69d894681a (patch)
treeecb8c10c6b543c78ec100efd1c0ad04536bc8dc0 /cmd
parentc0e29b4a31e330927b7a980209b2aae192f9bafe (diff)
downloadpodman-90884ac2d2394df67241410415f74b69d894681a.tar.gz
podman-90884ac2d2394df67241410415f74b69d894681a.tar.bz2
podman-90884ac2d2394df67241410415f74b69d894681a.zip
podmanv2 images user format
honor the format provided by user for output Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podmanV2/images/list.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/cmd/podmanV2/images/list.go b/cmd/podmanV2/images/list.go
index 2d6cb3596..6b02e239e 100644
--- a/cmd/podmanV2/images/list.go
+++ b/cmd/podmanV2/images/list.go
@@ -130,6 +130,9 @@ func writeJSON(imageS []*entities.ImageSummary) error {
}
func writeTemplate(imageS []*entities.ImageSummary, err error) error {
+ var (
+ hdr, row string
+ )
type image struct {
entities.ImageSummary
Repository string `json:"repository,omitempty"`
@@ -148,10 +151,15 @@ func writeTemplate(imageS []*entities.ImageSummary, err error) error {
listFlag.readOnly = true
}
}
-
- hdr, row := imageListFormat(listFlag)
+ if len(listFlag.format) < 1 {
+ hdr, row = imageListFormat(listFlag)
+ } else {
+ row = listFlag.format
+ if !strings.HasSuffix(row, "\n") {
+ row += "\n"
+ }
+ }
format := hdr + "{{range . }}" + row + "{{end}}"
-
tmpl := template.Must(template.New("list").Funcs(report.PodmanTemplateFuncs()).Parse(format))
w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
defer w.Flush()