aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman/networks
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/networks
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/networks')
-rw-r--r--cmd/podman/networks/rm.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/cmd/podman/networks/rm.go b/cmd/podman/networks/rm.go
index c2d3f655f..d734b2867 100644
--- a/cmd/podman/networks/rm.go
+++ b/cmd/podman/networks/rm.go
@@ -63,6 +63,9 @@ func networkRm(cmd *cobra.Command, args []string) error {
}
responses, err := registry.ContainerEngine().NetworkRm(registry.Context(), args, networkRmOptions)
if err != nil {
+ if networkRmOptions.Force && strings.Contains(err.Error(), define.ErrNoSuchNetwork.Error()) {
+ return nil
+ }
setExitCode(err)
return err
}
@@ -70,6 +73,9 @@ func networkRm(cmd *cobra.Command, args []string) error {
if r.Err == nil {
fmt.Println(r.Name)
} else {
+ if networkRmOptions.Force && strings.Contains(r.Err.Error(), define.ErrNoSuchNetwork.Error()) {
+ continue
+ }
setExitCode(r.Err)
errs = append(errs, r.Err)
}