mirror of
https://github.com/containers/podman.git
synced 2025-06-23 02:18:13 +08:00
Merge pull request #2181 from vrothberg/issue-2159
podman-inspect: don't ignore errors
This commit is contained in:
@ -20,6 +20,8 @@ const (
|
|||||||
JSONString = "json"
|
JSONString = "json"
|
||||||
// IDString const to save on duplicates for Go templates
|
// IDString const to save on duplicates for Go templates
|
||||||
IDString = "{{.ID}}"
|
IDString = "{{.ID}}"
|
||||||
|
|
||||||
|
parsingErrorStr = "Template parsing error"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Writer interface for outputs
|
// Writer interface for outputs
|
||||||
@ -96,7 +98,7 @@ func (t StdoutTemplateArray) Out() error {
|
|||||||
t.Template = strings.Replace(strings.TrimSpace(t.Template[5:]), " ", "\t", -1)
|
t.Template = strings.Replace(strings.TrimSpace(t.Template[5:]), " ", "\t", -1)
|
||||||
headerTmpl, err := template.New("header").Funcs(headerFunctions).Parse(t.Template)
|
headerTmpl, err := template.New("header").Funcs(headerFunctions).Parse(t.Template)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "Template parsing error")
|
return errors.Wrapf(err, parsingErrorStr)
|
||||||
}
|
}
|
||||||
err = headerTmpl.Execute(w, t.Fields)
|
err = headerTmpl.Execute(w, t.Fields)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -107,13 +109,12 @@ func (t StdoutTemplateArray) Out() error {
|
|||||||
t.Template = strings.Replace(t.Template, " ", "\t", -1)
|
t.Template = strings.Replace(t.Template, " ", "\t", -1)
|
||||||
tmpl, err := template.New("image").Funcs(basicFunctions).Parse(t.Template)
|
tmpl, err := template.New("image").Funcs(basicFunctions).Parse(t.Template)
|
||||||
if err != nil {
|
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)
|
basicTmpl := tmpl.Funcs(basicFunctions)
|
||||||
err = basicTmpl.Execute(w, img)
|
if err := basicTmpl.Execute(w, raw); err != nil {
|
||||||
if err != nil {
|
return errors.Wrapf(err, parsingErrorStr)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
if i != len(t.Output)-1 {
|
if i != len(t.Output)-1 {
|
||||||
fmt.Fprintln(w, "")
|
fmt.Fprintln(w, "")
|
||||||
|
@ -87,6 +87,9 @@ func inspectCmd(c *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inspectedObjects, iterateErr := iterateInput(getContext(), c, args, runtime, inspectType)
|
inspectedObjects, iterateErr := iterateInput(getContext(), c, args, runtime, inspectType)
|
||||||
|
if iterateErr != nil {
|
||||||
|
return iterateErr
|
||||||
|
}
|
||||||
|
|
||||||
var out formats.Writer
|
var out formats.Writer
|
||||||
if outputFormat != "" && outputFormat != formats.JSONString {
|
if outputFormat != "" && outputFormat != formats.JSONString {
|
||||||
@ -97,8 +100,7 @@ func inspectCmd(c *cli.Context) error {
|
|||||||
out = formats.JSONStructArray{Output: inspectedObjects}
|
out = formats.JSONStructArray{Output: inspectedObjects}
|
||||||
}
|
}
|
||||||
|
|
||||||
formats.Writer(out).Out()
|
return formats.Writer(out).Out()
|
||||||
return iterateErr
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// func iterateInput iterates the images|containers the user has requested and returns the inspect data and error
|
// func iterateInput iterates the images|containers the user has requested and returns the inspect data and error
|
||||||
|
Reference in New Issue
Block a user