diff options
author | Jhon Honce <jhonce@redhat.com> | 2020-10-28 11:03:09 -0700 |
---|---|---|
committer | Jhon Honce <jhonce@redhat.com> | 2020-10-29 10:14:08 -0700 |
commit | d60a0ddcc1784b2dd807cc8e4d4f3deb0c074171 (patch) | |
tree | b1ec22f25a3239f41f3e7e42159091d3d135aa20 /cmd/podman/images/list.go | |
parent | e439aec4fa867cda0672079dac0fe394dfb3306c (diff) | |
download | podman-d60a0ddcc1784b2dd807cc8e4d4f3deb0c074171.tar.gz podman-d60a0ddcc1784b2dd807cc8e4d4f3deb0c074171.tar.bz2 podman-d60a0ddcc1784b2dd807cc8e4d4f3deb0c074171.zip |
Restore --format table header support
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'cmd/podman/images/list.go')
-rw-r--r-- | cmd/podman/images/list.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/cmd/podman/images/list.go b/cmd/podman/images/list.go index 489b15086..e24631b24 100644 --- a/cmd/podman/images/list.go +++ b/cmd/podman/images/list.go @@ -12,6 +12,7 @@ import ( "github.com/containers/common/pkg/report" "github.com/containers/image/v5/docker/reference" + "github.com/containers/podman/v2/cmd/podman/parse" "github.com/containers/podman/v2/cmd/podman/registry" "github.com/containers/podman/v2/pkg/domain/entities" "github.com/docker/go-units" @@ -105,10 +106,10 @@ func images(cmd *cobra.Command, args []string) error { return err } switch { - case listFlag.quiet: - return writeID(imgs) case report.IsJSON(listFlag.format): return writeJSON(imgs) + case listFlag.quiet: + return writeID(imgs) default: if cmd.Flag("format").Changed { listFlag.noHeading = true // V1 compatibility @@ -171,9 +172,13 @@ func writeTemplate(imgs []imageReporter) error { } else { row = report.NormalizeFormat(listFlag.format) } + format := parse.EnforceRange(row) + + tmpl, err := template.New("list").Parse(format) + if err != nil { + return err + } - format := "{{range . }}" + row + "{{end}}" - tmpl := template.Must(template.New("list").Parse(format)) w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0) defer w.Flush() |