From eb4a746efcb9e76e29942461b97da797fd67109f Mon Sep 17 00:00:00 2001 From: Jhon Honce Date: Fri, 9 Oct 2020 09:13:22 -0700 Subject: Restore --format table support * system df * events * fix error handling from go routine * update tests to use gomega matchers for better error messages * system info * version * volume inspect Signed-off-by: Jhon Honce --- cmd/podman/system/info.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'cmd/podman/system/info.go') 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 } -- cgit v1.2.3-54-g00ecf