aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman/pods/rm.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2022-07-26 06:41:08 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2022-07-26 16:00:42 -0400
commit75419c5d887e23f93a465311b02bb76d8cea1940 (patch)
tree1bce4f62fd40b7996561d608db8613b6db22fc77 /cmd/podman/pods/rm.go
parent242639f4b1689231c37f909d3bda58b774a0ea96 (diff)
downloadpodman-75419c5d887e23f93a465311b02bb76d8cea1940.tar.gz
podman-75419c5d887e23f93a465311b02bb76d8cea1940.tar.bz2
podman-75419c5d887e23f93a465311b02bb76d8cea1940.zip
When removing objects specifying --force,podman should exit with 0
This Patch will cause podman COMMAND rm --force bogus not fail This is how Docker works, so Podman should follow this to allow existing scripts to convert from Docker to Podman. Fixes: #14612 Oprignal version of this patch came from wufan 1991849113@qq.com Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
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)