cli/command/plugin: use stdlib errors

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-09-08 20:07:10 +02:00
parent 5c8817b1b2
commit cd583313ee
4 changed files with 9 additions and 11 deletions

View File

@ -3,6 +3,7 @@ package plugin
import (
"context"
"encoding/json"
"errors"
"fmt"
"os"
"path/filepath"
@ -14,7 +15,6 @@ import (
"github.com/moby/go-archive/compression"
"github.com/moby/moby/api/types/plugin"
"github.com/moby/moby/client"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
@ -52,7 +52,7 @@ func validateContextDir(contextDir string) (string, error) {
}
if !stat.IsDir() {
return "", errors.Errorf("context must be a directory")
return "", errors.New("context must be a directory")
}
return absContextDir, nil

View File

@ -7,7 +7,6 @@ import (
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/moby/moby/client"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@ -36,7 +35,7 @@ func newEnableCommand(dockerCLI command.Cli) *cobra.Command {
func runEnable(ctx context.Context, dockerCli command.Cli, name string, opts client.PluginEnableOptions) error {
if opts.Timeout < 0 {
return errors.Errorf("negative timeout %d is invalid", opts.Timeout)
return fmt.Errorf("negative timeout %d is invalid", opts.Timeout)
}
return dockerCli.Client().PluginEnable(ctx, name, opts)
}

View File

@ -11,7 +11,6 @@ import (
"github.com/docker/cli/internal/prompt"
"github.com/moby/moby/api/types/plugin"
"github.com/moby/moby/client"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@ -82,7 +81,7 @@ func runInstall(ctx context.Context, dockerCLI command.Cli, opts pluginOptions)
return err
}
if _, ok := aref.(reference.Canonical); ok {
return errors.Errorf("invalid name: %s", opts.localName)
return fmt.Errorf("invalid name: %s", opts.localName)
}
localName = reference.FamiliarString(reference.TagNameOnly(aref))
}

View File

@ -2,6 +2,7 @@ package plugin
import (
"context"
"errors"
"fmt"
"github.com/distribution/reference"
@ -9,7 +10,6 @@ import (
"github.com/docker/cli/cli/command"
"github.com/docker/cli/internal/jsonstream"
"github.com/docker/cli/internal/prompt"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@ -41,11 +41,11 @@ func newUpgradeCommand(dockerCLI command.Cli) *cobra.Command {
func runUpgrade(ctx context.Context, dockerCLI command.Cli, opts pluginOptions) error {
p, _, err := dockerCLI.Client().PluginInspectWithRaw(ctx, opts.localName)
if err != nil {
return errors.Errorf("error reading plugin data: %v", err)
return fmt.Errorf("error reading plugin data: %w", err)
}
if p.Enabled {
return errors.Errorf("the plugin must be disabled before upgrading")
return errors.New("the plugin must be disabled before upgrading")
}
opts.localName = p.Name
@ -54,13 +54,13 @@ func runUpgrade(ctx context.Context, dockerCLI command.Cli, opts pluginOptions)
}
remote, err := reference.ParseNormalizedNamed(opts.remote)
if err != nil {
return errors.Wrap(err, "error parsing remote upgrade image reference")
return fmt.Errorf("error parsing remote upgrade image reference: %w", err)
}
remote = reference.TagNameOnly(remote)
old, err := reference.ParseNormalizedNamed(p.PluginReference)
if err != nil {
return errors.Wrap(err, "error parsing current image reference")
return fmt.Errorf("error parsing current image reference: %w", err)
}
old = reference.TagNameOnly(old)