From beae4d79d5c269c115bac272b9ed330e4b511f12 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Wed, 7 Sep 2022 15:32:50 +0200 Subject: [PATCH] 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 --- cmd/podman/inspect/inspect.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/podman/inspect/inspect.go b/cmd/podman/inspect/inspect.go index b90de1be81..69b76b70e8 100644 --- a/cmd/podman/inspect/inspect.go +++ b/cmd/podman/inspect/inspect.go @@ -16,7 +16,6 @@ import ( "github.com/containers/podman/v4/cmd/podman/validate" "github.com/containers/podman/v4/libpod/define" "github.com/containers/podman/v4/pkg/domain/entities" - "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -210,7 +209,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 {