From 61792de36ea2ea98f6e3aef3821d1b15beebf9e0 Mon Sep 17 00:00:00 2001 From: Jhon Honce Date: Thu, 18 Nov 2021 09:03:00 -0700 Subject: Refactor podman image command output Leverage new report.Formatter allowing better compatibility from podman command output. Follow on PR's will cover containers, etc. See #10974 Signed-off-by: Jhon Honce --- cmd/podman/pods/stats.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'cmd/podman/pods/stats.go') diff --git a/cmd/podman/pods/stats.go b/cmd/podman/pods/stats.go index ba2c1495b..a7bba3064 100644 --- a/cmd/podman/pods/stats.go +++ b/cmd/podman/pods/stats.go @@ -67,9 +67,7 @@ func stats(cmd *cobra.Command, args []string) error { return err } - row := report.NormalizeFormat(statsOptions.Format) - doJSON := report.IsJSON(row) - + doJSON := report.IsJSON(cmd.Flag("format").Value.String()) headers := report.Headers(entities.PodStatsReport{}, map[string]string{ "CPU": "CPU %", "MemUsage": "MEM USAGE/ LIMIT", @@ -96,6 +94,8 @@ func stats(cmd *cobra.Command, args []string) error { goterm.Flush() } if cmd.Flags().Changed("format") { + row := report.NormalizeFormat(statsOptions.Format) + row = report.EnforceRange(row) if err := printFormattedPodStatsLines(headers, row, reports); err != nil { return err } @@ -143,8 +143,6 @@ func printFormattedPodStatsLines(headerNames []map[string]string, row string, st return nil } - row = report.EnforceRange(row) - tmpl, err := report.NewTemplate("stats").Parse(row) if err != nil { return err -- cgit v1.2.3-54-g00ecf