Skip to content

Commit

Permalink
Merge pull request #7146 from rhatdan/format
Browse files Browse the repository at this point in the history
Don't crash when giving bogus format commands
  • Loading branch information
openshift-merge-robot authored Jul 30, 2020
2 parents c66ce8d + 9917fc0 commit 1170430
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 4 additions & 1 deletion cmd/podman/images/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ func history(cmd *cobra.Command, args []string) error {
}
format := hdr + "{{range . }}" + row + "{{end}}"

tmpl := template.Must(template.New("report").Parse(format))
tmpl, err := template.New("report").Parse(format)
if err != nil {
return err
}
w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
err = tmpl.Execute(w, hr)
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion cmd/podman/images/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ func writeTemplate(imgs []imageReporter) error {
}
}
format := hdr + "{{range . }}" + row + "{{end}}"
tmpl := template.Must(template.New("list").Parse(format))
tmpl, err := template.New("list").Parse(format)
if err != nil {
return err
}
tmpl = template.Must(tmpl, nil)
w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
defer w.Flush()
return tmpl.Execute(w, imgs)
Expand Down
6 changes: 5 additions & 1 deletion cmd/podman/system/connection/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ func list(_ *cobra.Command, _ []string) error {

// TODO: Allow user to override format
format := "{{range . }}{{.Name}}\t{{.Identity}}\t{{.URI}}\n{{end}}"
tmpl := template.Must(template.New("connection").Parse(format))
tmpl, err := template.New("connection").Parse(format)
if err != nil {
return err
}

w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
defer w.Flush()

Expand Down

0 comments on commit 1170430

Please sign in to comment.