diff options
Diffstat (limited to 'cmd/podman/images/rm.go')
-rw-r--r-- | cmd/podman/images/rm.go | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/cmd/podman/images/rm.go b/cmd/podman/images/rm.go index 18b22e51d..d3fd17440 100644 --- a/cmd/podman/images/rm.go +++ b/cmd/podman/images/rm.go @@ -3,11 +3,14 @@ package images import ( "errors" "fmt" + "strings" "github.com/containers/podman/v4/cmd/podman/common" "github.com/containers/podman/v4/cmd/podman/registry" + "github.com/containers/podman/v4/cmd/podman/utils" "github.com/containers/podman/v4/pkg/domain/entities" "github.com/containers/podman/v4/pkg/errorhandling" + "github.com/containers/storage/types" "github.com/spf13/cobra" "github.com/spf13/pflag" ) @@ -81,8 +84,19 @@ func rm(cmd *cobra.Command, args []string) error { fmt.Println("Deleted: " + d) } } - registry.SetExitCode(report.ExitCode) + for _, err := range rmErrors { + if !imageOpts.Force || !strings.Contains(err.Error(), types.ErrImageUnknown.Error()) { + registry.SetExitCode(report.ExitCode) + } + } } - return errorhandling.JoinErrors(rmErrors) + var errs utils.OutputErrors + for _, err := range rmErrors { + if imageOpts.Force && strings.Contains(err.Error(), types.ErrImageUnknown.Error()) { + continue + } + errs = append(errs, err) + } + return errorhandling.JoinErrors(errs) } |