podman inspect return exit code > 0 on print error

Unlikely to happen but when there is an error printing the data to
stdout (either as json or go template) we should not just log it and
exit with 0. Instead return a proper error and exit with 125.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger 2022-09-07 15:32:50 +02:00
parent 00240a0e2e
commit 43f7bdf822
No known key found for this signature in database
GPG Key ID: EB145DD938A3CAF2
1 changed files with 1 additions and 2 deletions

View File

@ -15,7 +15,6 @@ import (
"github.com/containers/podman/v4/cmd/podman/registry"
"github.com/containers/podman/v4/cmd/podman/validate"
"github.com/containers/podman/v4/pkg/domain/entities"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
@ -186,7 +185,7 @@ func (i *inspector) inspect(namesOrIDs []string) error {
err = rpt.Execute(data)
}
if err != nil {
logrus.Errorf("Printing inspect output: %v", err)
errs = append(errs, fmt.Errorf("printing inspect output: %w", err))
}
if len(errs) > 0 {