summaryrefslogtreecommitdiff
path: root/cmd/podman/pods
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-12-02 19:28:48 +0100
committerGitHub <noreply@github.com>2021-12-02 19:28:48 +0100
commit4ff0ba4c8731e3dc1d56010f80468260104f3abc (patch)
tree897ede56e699e7f39ad5aa949851bf7fd11ea3c3 /cmd/podman/pods
parentee39281c35e3ceca98c0c51c9cc5d792c56ba533 (diff)
parent61792de36ea2ea98f6e3aef3821d1b15beebf9e0 (diff)
downloadpodman-4ff0ba4c8731e3dc1d56010f80468260104f3abc.tar.gz
podman-4ff0ba4c8731e3dc1d56010f80468260104f3abc.tar.bz2
podman-4ff0ba4c8731e3dc1d56010f80468260104f3abc.zip
Merge pull request #12455 from jwhonce/issues/10974
Refactor podman image command output
Diffstat (limited to 'cmd/podman/pods')
-rw-r--r--cmd/podman/pods/inspect.go2
-rw-r--r--cmd/podman/pods/ps.go3
-rw-r--r--cmd/podman/pods/stats.go8
3 files changed, 7 insertions, 6 deletions
diff --git a/cmd/podman/pods/inspect.go b/cmd/podman/pods/inspect.go
index 96eaec3b9..d4b8df90e 100644
--- a/cmd/podman/pods/inspect.go
+++ b/cmd/podman/pods/inspect.go
@@ -64,11 +64,13 @@ func inspect(cmd *cobra.Command, args []string) error {
}
if report.IsJSON(inspectOptions.Format) {
+ json.MarshalIndent(responses, "", " ")
enc := json.NewEncoder(os.Stdout)
enc.SetIndent("", " ")
return enc.Encode(responses)
}
+ // cmd.Flags().Changed("format") must be true to reach this code
row := report.NormalizeFormat(inspectOptions.Format)
t, err := report.NewTemplate("inspect").Parse(row)
diff --git a/cmd/podman/pods/ps.go b/cmd/podman/pods/ps.go
index 60aadf224..808ec31b3 100644
--- a/cmd/podman/pods/ps.go
+++ b/cmd/podman/pods/ps.go
@@ -136,11 +136,12 @@ func pods(cmd *cobra.Command, _ []string) error {
renderHeaders = report.HasTable(psInput.Format)
row = report.NormalizeFormat(psInput.Format)
}
+ format := report.EnforceRange(row)
+
noHeading, _ := cmd.Flags().GetBool("noheading")
if noHeading {
renderHeaders = false
}
- format := report.EnforceRange(row)
tmpl, err := report.NewTemplate("list").Parse(format)
if err != nil {
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