summaryrefslogtreecommitdiff
path: root/cmd/podman/pods/rm.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-07-27 14:10:19 -0400
committerGitHub <noreply@github.com>2022-07-27 14:10:19 -0400
commit432348e8e4e95d32bb26ceca4d467ff9f726dd89 (patch)
treeb1551e08b62c37dc7ca7a0ce3f32e839802ed197 /cmd/podman/pods/rm.go
parenteea8e570f2af82944e61410e5e7dd9b540feae34 (diff)
parent75419c5d887e23f93a465311b02bb76d8cea1940 (diff)
downloadpodman-432348e8e4e95d32bb26ceca4d467ff9f726dd89.tar.gz
podman-432348e8e4e95d32bb26ceca4d467ff9f726dd89.tar.bz2
podman-432348e8e4e95d32bb26ceca4d467ff9f726dd89.zip
Merge pull request #14959 from rhatdan/rm
When removing objects specifying --force,podman should exit with 0
Diffstat (limited to 'cmd/podman/pods/rm.go')
-rw-r--r--cmd/podman/pods/rm.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/cmd/podman/pods/rm.go b/cmd/podman/pods/rm.go
index 2ffd968f9..0aa64481d 100644
--- a/cmd/podman/pods/rm.go
+++ b/cmd/podman/pods/rm.go
@@ -93,6 +93,9 @@ func removePods(namesOrIDs []string, rmOptions entities.PodRmOptions, printIDs b
responses, err := registry.ContainerEngine().PodRm(context.Background(), namesOrIDs, rmOptions)
if err != nil {
+ if rmOptions.Force && strings.Contains(err.Error(), define.ErrNoSuchPod.Error()) {
+ return nil
+ }
setExitCode(err)
return err
}
@@ -104,13 +107,15 @@ func removePods(namesOrIDs []string, rmOptions entities.PodRmOptions, printIDs b
fmt.Println(r.Id)
}
} else {
+ if rmOptions.Force && strings.Contains(r.Err.Error(), define.ErrNoSuchPod.Error()) {
+ continue
+ }
setExitCode(r.Err)
errs = append(errs, r.Err)
}
}
return errs.PrintErrors()
}
-
func setExitCode(err error) {
if errors.Is(err, define.ErrNoSuchPod) || strings.Contains(err.Error(), define.ErrNoSuchPod.Error()) {
registry.SetExitCode(1)