podman secret inspect: use report.Formatter over Template

Currently the podman command --format output code uses a mix of
report.Formatter and report.Template.

I patched report.Formatter to correctly handle newlines[1]. Since we
cannot fix this with report.Template we have to migrate all users to
report.Formatter. This ensures consistent behavior for all commands.

This change does not change the output, we can add a new test for the
newline bug when the common PR is vendored in.

[1] https://github.com/containers/common/pull/1146

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2022-09-07 14:43:52 +02:00
parent f5e13ded93
commit 377599f1f4

View File

@ -47,20 +47,15 @@ func inspect(cmd *cobra.Command, args []string) error {
}
if cmd.Flags().Changed("format") {
row := report.NormalizeFormat(format)
formatted := report.EnforceRange(row)
rpt := report.New(os.Stdout, cmd.Name())
defer rpt.Flush()
tmpl, err := report.NewTemplate("inspect").Parse(formatted)
rpt, err := rpt.Parse(report.OriginUser, format)
if err != nil {
return err
}
w, err := report.NewWriterDefault(os.Stdout)
if err != nil {
return err
}
defer w.Flush()
if err := tmpl.Execute(w, inspected); err != nil {
if err := rpt.Execute(inspected); err != nil {
return err
}
} else {