diff --git a/cli-plugins/manager/error.go b/cli-plugins/manager/error.go index cb0bbb5abd..144c11fa28 100644 --- a/cli-plugins/manager/error.go +++ b/cli-plugins/manager/error.go @@ -4,7 +4,7 @@ package manager import ( - "github.com/pkg/errors" + "fmt" ) // pluginError is set as Plugin.Err by NewPlugin if the plugin @@ -39,16 +39,16 @@ func (e *pluginError) MarshalText() (text []byte, err error) { } // wrapAsPluginError wraps an error in a pluginError with an -// additional message, analogous to errors.Wrapf. +// additional message. func wrapAsPluginError(err error, msg string) error { if err == nil { return nil } - return &pluginError{cause: errors.Wrap(err, msg)} + return &pluginError{cause: fmt.Errorf("%s: %w", msg, err)} } // NewPluginError creates a new pluginError, analogous to // errors.Errorf. func NewPluginError(msg string, args ...any) error { - return &pluginError{cause: errors.Errorf(msg, args...)} + return &pluginError{cause: fmt.Errorf(msg, args...)} } diff --git a/cli-plugins/manager/plugin.go b/cli-plugins/manager/plugin.go index e73d535d51..ec196df16f 100644 --- a/cli-plugins/manager/plugin.go +++ b/cli-plugins/manager/plugin.go @@ -3,6 +3,8 @@ package manager import ( "context" "encoding/json" + "errors" + "fmt" "os" "os/exec" "path/filepath" @@ -10,7 +12,6 @@ import ( "strings" "github.com/docker/cli/cli-plugins/metadata" - "github.com/pkg/errors" "github.com/spf13/cobra" ) @@ -45,14 +46,14 @@ func newPlugin(c Candidate, cmds []*cobra.Command) (Plugin, error) { // which would fail here, so there are all real errors. fullname := filepath.Base(path) if fullname == "." { - return Plugin{}, errors.Errorf("unable to determine basename of plugin candidate %q", path) + return Plugin{}, fmt.Errorf("unable to determine basename of plugin candidate %q", path) } var err error if fullname, err = trimExeSuffix(fullname); err != nil { - return Plugin{}, errors.Wrapf(err, "plugin candidate %q", path) + return Plugin{}, fmt.Errorf("plugin candidate %q: %w", path, err) } if !strings.HasPrefix(fullname, metadata.NamePrefix) { - return Plugin{}, errors.Errorf("plugin candidate %q: does not have %q prefix", path, metadata.NamePrefix) + return Plugin{}, fmt.Errorf("plugin candidate %q: does not have %q prefix", path, metadata.NamePrefix) } p := Plugin{ diff --git a/cli-plugins/manager/suffix_windows.go b/cli-plugins/manager/suffix_windows.go index 53b507c87d..a00be881f9 100644 --- a/cli-plugins/manager/suffix_windows.go +++ b/cli-plugins/manager/suffix_windows.go @@ -1,22 +1,16 @@ package manager import ( + "fmt" "path/filepath" "strings" - - "github.com/pkg/errors" ) -// This is made slightly more complex due to needing to be case insensitive. +// This is made slightly more complex due to needing to be case-insensitive. func trimExeSuffix(s string) (string, error) { ext := filepath.Ext(s) - if ext == "" { - return "", errors.Errorf("path %q lacks required file extension", s) - } - - exe := ".exe" - if !strings.EqualFold(ext, exe) { - return "", errors.Errorf("path %q lacks required %q suffix", s, exe) + if ext == "" || !strings.EqualFold(ext, ".exe") { + return "", fmt.Errorf("path %q lacks required file extension (.exe)", s) } return strings.TrimSuffix(s, ext), nil }