summaryrefslogtreecommitdiff
path: root/cmd/podman/formats/formats.go
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2019-01-18 14:30:45 +0100
committerValentin Rothberg <rothberg@redhat.com>2019-01-18 14:30:45 +0100
commitf1c5b1e912ab380ca9e7c2adea39c0c5e974794d (patch)
tree1bef6c081b7a772689cd7af1be18138d383c264e /cmd/podman/formats/formats.go
parente3dc6609d05695e649e76d4505e4761cafebcef6 (diff)
downloadpodman-f1c5b1e912ab380ca9e7c2adea39c0c5e974794d.tar.gz
podman-f1c5b1e912ab380ca9e7c2adea39c0c5e974794d.tar.bz2
podman-f1c5b1e912ab380ca9e7c2adea39c0c5e974794d.zip
podman-inspect: don't ignore errors
Return errors when executing the --format templates. Otherwise, Podman will just silently ignore them and not print any output that could guide user into solving the issue. Fixes: #2159 Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'cmd/podman/formats/formats.go')
-rw-r--r--cmd/podman/formats/formats.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/cmd/podman/formats/formats.go b/cmd/podman/formats/formats.go
index 3da0ea385..c454c39bd 100644
--- a/cmd/podman/formats/formats.go
+++ b/cmd/podman/formats/formats.go
@@ -20,6 +20,8 @@ const (
JSONString = "json"
// IDString const to save on duplicates for Go templates
IDString = "{{.ID}}"
+
+ parsingErrorStr = "Template parsing error"
)
// Writer interface for outputs
@@ -96,7 +98,7 @@ func (t StdoutTemplateArray) Out() error {
t.Template = strings.Replace(strings.TrimSpace(t.Template[5:]), " ", "\t", -1)
headerTmpl, err := template.New("header").Funcs(headerFunctions).Parse(t.Template)
if err != nil {
- return errors.Wrapf(err, "Template parsing error")
+ return errors.Wrapf(err, parsingErrorStr)
}
err = headerTmpl.Execute(w, t.Fields)
if err != nil {
@@ -107,13 +109,12 @@ func (t StdoutTemplateArray) Out() error {
t.Template = strings.Replace(t.Template, " ", "\t", -1)
tmpl, err := template.New("image").Funcs(basicFunctions).Parse(t.Template)
if err != nil {
- return errors.Wrapf(err, "Template parsing error")
+ return errors.Wrapf(err, parsingErrorStr)
}
- for i, img := range t.Output {
+ for i, raw := range t.Output {
basicTmpl := tmpl.Funcs(basicFunctions)
- err = basicTmpl.Execute(w, img)
- if err != nil {
- return err
+ if err := basicTmpl.Execute(w, raw); err != nil {
+ return errors.Wrapf(err, parsingErrorStr)
}
if i != len(t.Output)-1 {
fmt.Fprintln(w, "")