diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2022-07-26 06:41:08 -0400 |
---|---|---|
committer | Matthew Heon <mheon@redhat.com> | 2022-08-10 16:46:05 -0400 |
commit | 32848b95f6fcf9e8dcd51f23f43846d66886f1ac (patch) | |
tree | a3b5ece563a8cc7cc096eb0703f901279dc12a39 /cmd/podman/volumes | |
parent | 312bef288bd7b7cd2e52d25e4f5911f730fad4e8 (diff) | |
download | podman-32848b95f6fcf9e8dcd51f23f43846d66886f1ac.tar.gz podman-32848b95f6fcf9e8dcd51f23f43846d66886f1ac.tar.bz2 podman-32848b95f6fcf9e8dcd51f23f43846d66886f1ac.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/volumes')
-rw-r--r-- | cmd/podman/volumes/rm.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/cmd/podman/volumes/rm.go b/cmd/podman/volumes/rm.go index c160b8623..1383da279 100644 --- a/cmd/podman/volumes/rm.go +++ b/cmd/podman/volumes/rm.go @@ -65,6 +65,9 @@ func rm(cmd *cobra.Command, args []string) error { } responses, err := registry.ContainerEngine().VolumeRm(context.Background(), args, rmOptions) if err != nil { + if rmOptions.Force && strings.Contains(err.Error(), define.ErrNoSuchVolume.Error()) { + return nil + } setExitCode(err) return err } @@ -72,6 +75,9 @@ func rm(cmd *cobra.Command, args []string) error { if r.Err == nil { fmt.Println(r.Id) } else { + if rmOptions.Force && strings.Contains(r.Err.Error(), define.ErrNoSuchVolume.Error()) { + continue + } setExitCode(r.Err) errs = append(errs, r.Err) } |