Skip to content

Commit

Permalink
podman secret inspect: use report.Formatter over Template
Browse files Browse the repository at this point in the history
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] containers/common#1146

Signed-off-by: Paul Holzinger <[email protected]>
  • Loading branch information
Luap99 committed Sep 13, 2022
1 parent f5e13de commit 377599f
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions cmd/podman/secrets/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 377599f

Please sign in to comment.