Skip to content

Commit 1168edb

Browse files
committed
cli/command/volume: use stdlib errors, remove errdefs uses
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 981e75e commit 1168edb

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

cli/command/volume/create.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package volume
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"sort"
78
"strings"
@@ -11,7 +12,6 @@ import (
1112
"github.com/docker/cli/cli/command/completion"
1213
"github.com/docker/cli/opts"
1314
"github.com/docker/docker/api/types/volume"
14-
"github.com/pkg/errors"
1515
"github.com/spf13/cobra"
1616
"github.com/spf13/pflag"
1717
)
@@ -52,7 +52,7 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command {
5252
RunE: func(cmd *cobra.Command, args []string) error {
5353
if len(args) == 1 {
5454
if options.name != "" {
55-
return errors.Errorf("conflicting options: cannot specify a volume-name through both --name and as a positional arg")
55+
return errors.New("conflicting options: cannot specify a volume-name through both --name and as a positional arg")
5656
}
5757
options.name = args[0]
5858
}

cli/command/volume/prune.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package volume
22

33
import (
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
108115
func RunPrune(ctx context.Context, dockerCli command.Cli, _ bool, filter opts.FilterOpt) (uint64, string, error) {

cli/command/volume/update.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ package volume
22

33
import (
44
"context"
5+
"errors"
56

67
"github.com/docker/cli/cli"
78
"github.com/docker/cli/cli/command"
89
"github.com/docker/cli/cli/command/completion"
910
"github.com/docker/docker/api/types/volume"
10-
"github.com/pkg/errors"
1111
"github.com/spf13/cobra"
1212
"github.com/spf13/pflag"
1313
)
@@ -50,7 +50,7 @@ func runUpdate(ctx context.Context, dockerCli command.Cli, volumeID, availabilit
5050
}
5151

5252
if vol.ClusterVolume == nil {
53-
return errors.New("Can only update cluster volumes")
53+
return errors.New("can only update cluster volumes")
5454
}
5555

5656
if flags.Changed("availability") {

0 commit comments

Comments
 (0)