Replace fmt.Errorf() with errors.Errorf() in the cli
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
@ -13,6 +13,7 @@ import (
|
||||
"github.com/docker/docker/cli"
|
||||
"github.com/docker/docker/cli/command"
|
||||
"github.com/docker/docker/pkg/archive"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
@ -50,7 +51,7 @@ func validateContextDir(contextDir string) (string, error) {
|
||||
}
|
||||
|
||||
if !stat.IsDir() {
|
||||
return "", fmt.Errorf("context must be a directory")
|
||||
return "", errors.Errorf("context must be a directory")
|
||||
}
|
||||
|
||||
return absContextDir, nil
|
||||
|
||||
@ -6,6 +6,7 @@ import (
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/cli"
|
||||
"github.com/docker/docker/cli/command"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
@ -36,7 +37,7 @@ func newEnableCommand(dockerCli *command.DockerCli) *cobra.Command {
|
||||
func runEnable(dockerCli *command.DockerCli, opts *enableOpts) error {
|
||||
name := opts.name
|
||||
if opts.timeout < 0 {
|
||||
return fmt.Errorf("negative timeout %d is invalid", opts.timeout)
|
||||
return errors.Errorf("negative timeout %d is invalid", opts.timeout)
|
||||
}
|
||||
|
||||
if err := dockerCli.Client().PluginEnable(context.Background(), name, types.PluginEnableOptions{Timeout: opts.timeout}); err != nil {
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
@ -12,6 +11,7 @@ import (
|
||||
"github.com/docker/docker/cli/command/image"
|
||||
"github.com/docker/docker/pkg/jsonmessage"
|
||||
"github.com/docker/docker/registry"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
"golang.org/x/net/context"
|
||||
@ -92,7 +92,7 @@ func buildPullConfig(ctx context.Context, dockerCli *command.DockerCli, opts plu
|
||||
ref = reference.TagNameOnly(ref)
|
||||
nt, ok := ref.(reference.NamedTagged)
|
||||
if !ok {
|
||||
return types.PluginInstallOptions{}, fmt.Errorf("invalid name: %s", ref.String())
|
||||
return types.PluginInstallOptions{}, errors.Errorf("invalid name: %s", ref.String())
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
@ -132,7 +132,7 @@ func runInstall(dockerCli *command.DockerCli, opts pluginOptions) error {
|
||||
return err
|
||||
}
|
||||
if _, ok := aref.(reference.Canonical); ok {
|
||||
return fmt.Errorf("invalid name: %s", opts.localName)
|
||||
return errors.Errorf("invalid name: %s", opts.localName)
|
||||
}
|
||||
localName = reference.FamiliarString(reference.TagNameOnly(aref))
|
||||
}
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/docker/distribution/reference"
|
||||
@ -11,6 +9,7 @@ import (
|
||||
"github.com/docker/docker/cli/command/image"
|
||||
"github.com/docker/docker/pkg/jsonmessage"
|
||||
"github.com/docker/docker/registry"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@ -37,7 +36,7 @@ func runPush(dockerCli *command.DockerCli, name string) error {
|
||||
return err
|
||||
}
|
||||
if _, ok := named.(reference.Canonical); ok {
|
||||
return fmt.Errorf("invalid name: %s", name)
|
||||
return errors.Errorf("invalid name: %s", name)
|
||||
}
|
||||
|
||||
named = reference.TagNameOnly(named)
|
||||
|
||||
@ -39,11 +39,11 @@ func runUpgrade(dockerCli *command.DockerCli, opts pluginOptions) error {
|
||||
ctx := context.Background()
|
||||
p, _, err := dockerCli.Client().PluginInspectWithRaw(ctx, opts.localName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error reading plugin data: %v", err)
|
||||
return errors.Errorf("error reading plugin data: %v", err)
|
||||
}
|
||||
|
||||
if p.Enabled {
|
||||
return fmt.Errorf("the plugin must be disabled before upgrading")
|
||||
return errors.Errorf("the plugin must be disabled before upgrading")
|
||||
}
|
||||
|
||||
opts.localName = p.Name
|
||||
|
||||
Reference in New Issue
Block a user