Skip to content

Commit 3717e2b

Browse files
committed
Add --include-protected flag to volume rm command
1 parent 7f5e09e commit 3717e2b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

cmd/podman/volumes/rm.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ var (
3333
)
3434

3535
var (
36-
rmOptions = entities.VolumeRmOptions{}
37-
stopTimeout int
36+
rmOptions = entities.VolumeRmOptions{}
37+
stopTimeout int
38+
includeProtected bool
3839
)
3940

4041
func init() {
@@ -45,6 +46,7 @@ func init() {
4546
flags := rmCommand.Flags()
4647
flags.BoolVarP(&rmOptions.All, "all", "a", false, "Remove all volumes")
4748
flags.BoolVarP(&rmOptions.Force, "force", "f", false, "Remove a volume by force, even if it is being used by a container")
49+
flags.BoolVar(&includeProtected, "include-protected", false, "Include protected volumes in removal operation")
4850
timeFlagName := "time"
4951
flags.IntVarP(&stopTimeout, timeFlagName, "t", int(containerConfig.Engine.StopTimeout), "Seconds to wait for running containers to stop before killing the container")
5052
_ = rmCommand.RegisterFlagCompletionFunc(timeFlagName, completion.AutocompleteNone)
@@ -64,6 +66,7 @@ func rm(cmd *cobra.Command, args []string) error {
6466
timeout := uint(stopTimeout)
6567
rmOptions.Timeout = &timeout
6668
}
69+
rmOptions.IncludeProtected = includeProtected
6770
responses, err := registry.ContainerEngine().VolumeRm(context.Background(), args, rmOptions)
6871
if err != nil {
6972
if rmOptions.Force && strings.Contains(err.Error(), define.ErrNoSuchVolume.Error()) {
@@ -76,9 +79,6 @@ func rm(cmd *cobra.Command, args []string) error {
7679
if r.Err == nil {
7780
fmt.Println(r.Id)
7881
} else {
79-
if rmOptions.Force && strings.Contains(r.Err.Error(), define.ErrNoSuchVolume.Error()) {
80-
continue
81-
}
8282
setExitCode(r.Err)
8383
errs = append(errs, r.Err)
8484
}

0 commit comments

Comments
 (0)