diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-10-14 13:07:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-14 13:07:11 -0400 |
commit | e3eb6fd0e4115162e10caf6ae2196fd8774657e0 (patch) | |
tree | 9c75804b98eefa34a2cc924c8ccb2b8fc9c40d01 /cmd/podman/system/info.go | |
parent | d30b4b7aa5076c3192faada7d408f039a40414eb (diff) | |
parent | eb4a746efcb9e76e29942461b97da797fd67109f (diff) | |
download | podman-e3eb6fd0e4115162e10caf6ae2196fd8774657e0.tar.gz podman-e3eb6fd0e4115162e10caf6ae2196fd8774657e0.tar.bz2 podman-e3eb6fd0e4115162e10caf6ae2196fd8774657e0.zip |
Merge pull request #7987 from jwhonce/jira/run-898-5
Restore --format table support
Diffstat (limited to 'cmd/podman/system/info.go')
-rw-r--r-- | cmd/podman/system/info.go | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/cmd/podman/system/info.go b/cmd/podman/system/info.go index 3e3c99488..ee720abf8 100644 --- a/cmd/podman/system/info.go +++ b/cmd/podman/system/info.go @@ -69,26 +69,25 @@ func info(cmd *cobra.Command, args []string) error { return err } - if parse.MatchesJSONFormat(inFormat) { + switch { + case parse.MatchesJSONFormat(inFormat): b, err := json.MarshalIndent(info, "", " ") if err != nil { return err } fmt.Println(string(b)) - return nil - } - if !cmd.Flag("format").Changed { + case cmd.Flags().Changed("format"): + tmpl, err := template.New("info").Parse(inFormat) + if err != nil { + return err + } + return tmpl.Execute(os.Stdout, info) + default: b, err := yaml.Marshal(info) if err != nil { return err } fmt.Println(string(b)) - return nil - } - tmpl, err := template.New("info").Parse(inFormat) - if err != nil { - return err } - err = tmpl.Execute(os.Stdout, info) - return err + return nil } |