diff --git a/cli/command/volume/create_test.go b/cli/command/volume/create_test.go index f5c711bf8842..a37f9655b1d0 100644 --- a/cli/command/volume/create_test.go +++ b/cli/command/volume/create_test.go @@ -50,6 +50,7 @@ func TestVolumeCreateErrors(t *testing.T) { cmd.Flags().Set(key, value) } cmd.SetOut(io.Discard) + cmd.SetErr(io.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/volume/inspect_test.go b/cli/command/volume/inspect_test.go index bf1643752417..62c9c00aa83c 100644 --- a/cli/command/volume/inspect_test.go +++ b/cli/command/volume/inspect_test.go @@ -62,6 +62,7 @@ func TestVolumeInspectErrors(t *testing.T) { cmd.Flags().Set(key, value) } cmd.SetOut(io.Discard) + cmd.SetErr(io.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/volume/list_test.go b/cli/command/volume/list_test.go index dbed5a160629..45bbc955e471 100644 --- a/cli/command/volume/list_test.go +++ b/cli/command/volume/list_test.go @@ -43,6 +43,7 @@ func TestVolumeListErrors(t *testing.T) { cmd.Flags().Set(key, value) } cmd.SetOut(io.Discard) + cmd.SetErr(io.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/volume/prune.go b/cli/command/volume/prune.go index 16fd5508988e..e126f133b15a 100644 --- a/cli/command/volume/prune.go +++ b/cli/command/volume/prune.go @@ -8,11 +8,15 @@ import ( "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/opts" + "github.com/docker/docker/api/types/versions" + "github.com/docker/docker/errdefs" units "github.com/docker/go-units" + "github.com/pkg/errors" "github.com/spf13/cobra" ) type pruneOptions struct { + all bool force bool filter opts.FilterOpt } @@ -41,18 +45,37 @@ func NewPruneCommand(dockerCli command.Cli) *cobra.Command { } flags := cmd.Flags() + flags.BoolVarP(&options.all, "all", "a", false, "Remove all unused volumes, not just anonymous ones") + flags.SetAnnotation("all", "version", []string{"1.42"}) flags.BoolVarP(&options.force, "force", "f", false, "Do not prompt for confirmation") flags.Var(&options.filter, "filter", `Provide filter values (e.g. "label=