Skip to content

Commit cd58331

Browse files
committed
cli/command/plugin: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 5c8817b commit cd58331

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

cli/command/plugin/create.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package plugin
33
import (
44
"context"
55
"encoding/json"
6+
"errors"
67
"fmt"
78
"os"
89
"path/filepath"
@@ -14,7 +15,6 @@ import (
1415
"github.com/moby/go-archive/compression"
1516
"github.com/moby/moby/api/types/plugin"
1617
"github.com/moby/moby/client"
17-
"github.com/pkg/errors"
1818
"github.com/sirupsen/logrus"
1919
"github.com/spf13/cobra"
2020
)
@@ -52,7 +52,7 @@ func validateContextDir(contextDir string) (string, error) {
5252
}
5353

5454
if !stat.IsDir() {
55-
return "", errors.Errorf("context must be a directory")
55+
return "", errors.New("context must be a directory")
5656
}
5757

5858
return absContextDir, nil

cli/command/plugin/enable.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/docker/cli/cli"
88
"github.com/docker/cli/cli/command"
99
"github.com/moby/moby/client"
10-
"github.com/pkg/errors"
1110
"github.com/spf13/cobra"
1211
)
1312

@@ -36,7 +35,7 @@ func newEnableCommand(dockerCLI command.Cli) *cobra.Command {
3635

3736
func runEnable(ctx context.Context, dockerCli command.Cli, name string, opts client.PluginEnableOptions) error {
3837
if opts.Timeout < 0 {
39-
return errors.Errorf("negative timeout %d is invalid", opts.Timeout)
38+
return fmt.Errorf("negative timeout %d is invalid", opts.Timeout)
4039
}
4140
return dockerCli.Client().PluginEnable(ctx, name, opts)
4241
}

cli/command/plugin/install.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/docker/cli/internal/prompt"
1212
"github.com/moby/moby/api/types/plugin"
1313
"github.com/moby/moby/client"
14-
"github.com/pkg/errors"
1514
"github.com/spf13/cobra"
1615
)
1716

@@ -82,7 +81,7 @@ func runInstall(ctx context.Context, dockerCLI command.Cli, opts pluginOptions)
8281
return err
8382
}
8483
if _, ok := aref.(reference.Canonical); ok {
85-
return errors.Errorf("invalid name: %s", opts.localName)
84+
return fmt.Errorf("invalid name: %s", opts.localName)
8685
}
8786
localName = reference.FamiliarString(reference.TagNameOnly(aref))
8887
}

cli/command/plugin/upgrade.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ package plugin
22

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

78
"github.com/distribution/reference"
89
"github.com/docker/cli/cli"
910
"github.com/docker/cli/cli/command"
1011
"github.com/docker/cli/internal/jsonstream"
1112
"github.com/docker/cli/internal/prompt"
12-
"github.com/pkg/errors"
1313
"github.com/spf13/cobra"
1414
)
1515

@@ -41,11 +41,11 @@ func newUpgradeCommand(dockerCLI command.Cli) *cobra.Command {
4141
func runUpgrade(ctx context.Context, dockerCLI command.Cli, opts pluginOptions) error {
4242
p, _, err := dockerCLI.Client().PluginInspectWithRaw(ctx, opts.localName)
4343
if err != nil {
44-
return errors.Errorf("error reading plugin data: %v", err)
44+
return fmt.Errorf("error reading plugin data: %w", err)
4545
}
4646

4747
if p.Enabled {
48-
return errors.Errorf("the plugin must be disabled before upgrading")
48+
return errors.New("the plugin must be disabled before upgrading")
4949
}
5050

5151
opts.localName = p.Name
@@ -54,13 +54,13 @@ func runUpgrade(ctx context.Context, dockerCLI command.Cli, opts pluginOptions)
5454
}
5555
remote, err := reference.ParseNormalizedNamed(opts.remote)
5656
if err != nil {
57-
return errors.Wrap(err, "error parsing remote upgrade image reference")
57+
return fmt.Errorf("error parsing remote upgrade image reference: %w", err)
5858
}
5959
remote = reference.TagNameOnly(remote)
6060

6161
old, err := reference.ParseNormalizedNamed(p.PluginReference)
6262
if err != nil {
63-
return errors.Wrap(err, "error parsing current image reference")
63+
return fmt.Errorf("error parsing current image reference: %w", err)
6464
}
6565
old = reference.TagNameOnly(old)
6666

0 commit comments

Comments
 (0)