diff --git a/cmd/podman/system/info.go b/cmd/podman/system/info.go index 296fa4def7..9613d5e56f 100644 --- a/cmd/podman/system/info.go +++ b/cmd/podman/system/info.go @@ -3,7 +3,6 @@ package system import ( "fmt" "os" - "text/template" "github.com/containers/common/pkg/completion" "github.com/containers/common/pkg/report" @@ -86,14 +85,16 @@ func info(cmd *cobra.Command, args []string) error { } fmt.Println(string(b)) case cmd.Flags().Changed("format"): - // Cannot use report.New() as it enforces {{range .}} for OriginUser templates - tmpl := template.New(cmd.Name()).Funcs(template.FuncMap(report.DefaultFuncs)) - inFormat = report.NormalizeFormat(inFormat) - tmpl, err := tmpl.Parse(inFormat) + rpt := report.New(os.Stdout, cmd.Name()) + defer rpt.Flush() + + // Use OriginUnknown so it does not add an extra range since it + // will only be called for a single element and not a slice. + rpt, err = rpt.Parse(report.OriginUnknown, inFormat) if err != nil { return err } - return tmpl.Execute(os.Stdout, info) + return rpt.Execute(info) default: b, err := yaml.Marshal(info) if err != nil { diff --git a/test/system/610-format.bats b/test/system/610-format.bats index 77921b9a20..3781bc910d 100644 --- a/test/system/610-format.bats +++ b/test/system/610-format.bats @@ -20,8 +20,6 @@ function teardown() { # remove the entire lines, except for pod-inspect, just remove the SKIP # but leave "mypod") extra_args_table=" -info | SKIP -system info | SKIP machine info | SKIP version | SKIP