@@ -2,6 +2,7 @@ package volume
22
33import (
44 "context"
5+ "errors"
56 "fmt"
67
78 "github.com/docker/cli/cli"
@@ -10,9 +11,7 @@ import (
1011 "github.com/docker/cli/internal/prompt"
1112 "github.com/docker/cli/opts"
1213 "github.com/docker/docker/api/types/versions"
13- "github.com/docker/docker/errdefs"
14- units "github.com/docker/go-units"
15- "github.com/pkg/errors"
14+ "github.com/docker/go-units"
1615 "github.com/spf13/cobra"
1716)
1817
@@ -68,7 +67,7 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions)
6867 if versions .GreaterThanOrEqualTo (dockerCli .CurrentVersion (), "1.42" ) {
6968 if options .all {
7069 if pruneFilters .Contains ("all" ) {
71- return 0 , "" , errdefs . InvalidParameter ( errors .New ("conflicting options: cannot specify both --all and --filter all=1" ))
70+ return 0 , "" , invalidParamErr { errors .New ("conflicting options: cannot specify both --all and --filter all=1" )}
7271 }
7372 pruneFilters .Add ("all" , "true" )
7473 warning = allVolumesWarning
@@ -83,7 +82,7 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions)
8382 return 0 , "" , err
8483 }
8584 if ! r {
86- return 0 , "" , errdefs . Cancelled ( errors .New ("volume prune has been cancelled" ))
85+ return 0 , "" , cancelledErr { errors .New ("volume prune has been cancelled" )}
8786 }
8887 }
8988
@@ -103,6 +102,14 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions)
103102 return spaceReclaimed , output , nil
104103}
105104
105+ type invalidParamErr struct { error }
106+
107+ func (invalidParamErr ) InvalidParameter () {}
108+
109+ type cancelledErr struct { error }
110+
111+ func (cancelledErr ) Cancelled () {}
112+
106113// RunPrune calls the Volume Prune API
107114// This returns the amount of space reclaimed and a detailed output string
108115func RunPrune (ctx context.Context , dockerCli command.Cli , _ bool , filter opts.FilterOpt ) (uint64 , string , error ) {
0 commit comments