diff --git a/cli/command/volume/create.go b/cli/command/volume/create.go index 164ff2ebfb..8c13f65a74 100644 --- a/cli/command/volume/create.go +++ b/cli/command/volume/create.go @@ -2,6 +2,7 @@ package volume import ( "context" + "errors" "fmt" "sort" "strings" @@ -11,7 +12,6 @@ import ( "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/opts" "github.com/docker/docker/api/types/volume" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/pflag" ) @@ -52,7 +52,7 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { if len(args) == 1 { if options.name != "" { - return errors.Errorf("conflicting options: cannot specify a volume-name through both --name and as a positional arg") + return errors.New("conflicting options: cannot specify a volume-name through both --name and as a positional arg") } options.name = args[0] } diff --git a/cli/command/volume/prune.go b/cli/command/volume/prune.go index c366e347f6..0765e02289 100644 --- a/cli/command/volume/prune.go +++ b/cli/command/volume/prune.go @@ -2,6 +2,7 @@ package volume import ( "context" + "errors" "fmt" "github.com/docker/cli/cli" @@ -10,9 +11,7 @@ import ( "github.com/docker/cli/internal/prompt" "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/docker/go-units" "github.com/spf13/cobra" ) @@ -68,7 +67,7 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) if versions.GreaterThanOrEqualTo(dockerCli.CurrentVersion(), "1.42") { if options.all { if pruneFilters.Contains("all") { - return 0, "", errdefs.InvalidParameter(errors.New("conflicting options: cannot specify both --all and --filter all=1")) + return 0, "", invalidParamErr{errors.New("conflicting options: cannot specify both --all and --filter all=1")} } pruneFilters.Add("all", "true") warning = allVolumesWarning @@ -83,7 +82,7 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) return 0, "", err } if !r { - return 0, "", errdefs.Cancelled(errors.New("volume prune has been cancelled")) + return 0, "", cancelledErr{errors.New("volume prune has been cancelled")} } } @@ -103,6 +102,14 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) return spaceReclaimed, output, nil } +type invalidParamErr struct{ error } + +func (invalidParamErr) InvalidParameter() {} + +type cancelledErr struct{ error } + +func (cancelledErr) Cancelled() {} + // RunPrune calls the Volume Prune API // This returns the amount of space reclaimed and a detailed output string func RunPrune(ctx context.Context, dockerCli command.Cli, _ bool, filter opts.FilterOpt) (uint64, string, error) { diff --git a/cli/command/volume/update.go b/cli/command/volume/update.go index 42ce9ac586..5512c3f367 100644 --- a/cli/command/volume/update.go +++ b/cli/command/volume/update.go @@ -2,12 +2,12 @@ package volume import ( "context" + "errors" "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command/completion" "github.com/docker/docker/api/types/volume" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/pflag" ) @@ -50,7 +50,7 @@ func runUpdate(ctx context.Context, dockerCli command.Cli, volumeID, availabilit } if vol.ClusterVolume == nil { - return errors.New("Can only update cluster volumes") + return errors.New("can only update cluster volumes") } if flags.Changed("availability") {