diff --git a/cli/command/checkpoint/create_test.go b/cli/command/checkpoint/create_test.go index b3b7372080..6015dc03dd 100644 --- a/cli/command/checkpoint/create_test.go +++ b/cli/command/checkpoint/create_test.go @@ -1,13 +1,13 @@ package checkpoint import ( + "errors" "io" "strings" "testing" "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/checkpoint" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -29,7 +29,7 @@ func TestCheckpointCreateErrors(t *testing.T) { { args: []string{"foo", "bar"}, checkpointCreateFunc: func(container string, options checkpoint.CreateOptions) error { - return errors.Errorf("error creating checkpoint for container foo") + return errors.New("error creating checkpoint for container foo") }, expectedError: "error creating checkpoint for container foo", }, diff --git a/cli/command/checkpoint/list_test.go b/cli/command/checkpoint/list_test.go index 437cc1b359..33d2e6379c 100644 --- a/cli/command/checkpoint/list_test.go +++ b/cli/command/checkpoint/list_test.go @@ -1,12 +1,12 @@ package checkpoint import ( + "errors" "io" "testing" "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/checkpoint" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" "gotest.tools/v3/golden" @@ -29,7 +29,7 @@ func TestCheckpointListErrors(t *testing.T) { { args: []string{"foo"}, checkpointListFunc: func(container string, options checkpoint.ListOptions) ([]checkpoint.Summary, error) { - return []checkpoint.Summary{}, errors.Errorf("error getting checkpoints for container foo") + return []checkpoint.Summary{}, errors.New("error getting checkpoints for container foo") }, expectedError: "error getting checkpoints for container foo", }, diff --git a/cli/command/checkpoint/remove_test.go b/cli/command/checkpoint/remove_test.go index ae8402edb2..7064fbf1ee 100644 --- a/cli/command/checkpoint/remove_test.go +++ b/cli/command/checkpoint/remove_test.go @@ -1,12 +1,12 @@ package checkpoint import ( + "errors" "io" "testing" "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/checkpoint" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -28,7 +28,7 @@ func TestCheckpointRemoveErrors(t *testing.T) { { args: []string{"foo", "bar"}, checkpointDeleteFunc: func(container string, options checkpoint.DeleteOptions) error { - return errors.Errorf("error deleting checkpoint") + return errors.New("error deleting checkpoint") }, expectedError: "error deleting checkpoint", }, diff --git a/cli/command/cli_test.go b/cli/command/cli_test.go index c8a724346f..b71e83a1e4 100644 --- a/cli/command/cli_test.go +++ b/cli/command/cli_test.go @@ -3,6 +3,7 @@ package command import ( "bytes" "context" + "errors" "fmt" "io" "net" @@ -22,7 +23,6 @@ import ( "github.com/docker/docker/api" "github.com/docker/docker/api/types" "github.com/docker/docker/client" - "github.com/pkg/errors" "gotest.tools/v3/assert" "gotest.tools/v3/fs" ) diff --git a/cli/command/config/create_test.go b/cli/command/config/create_test.go index 855fab3fdf..9c919f8800 100644 --- a/cli/command/config/create_test.go +++ b/cli/command/config/create_test.go @@ -2,6 +2,8 @@ package config import ( "context" + "errors" + "fmt" "io" "os" "path/filepath" @@ -12,7 +14,6 @@ import ( "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" "gotest.tools/v3/golden" @@ -37,7 +38,7 @@ func TestConfigCreateErrors(t *testing.T) { { args: []string{"name", filepath.Join("testdata", configDataFile)}, configCreateFunc: func(_ context.Context, configSpec swarm.ConfigSpec) (types.ConfigCreateResponse, error) { - return types.ConfigCreateResponse{}, errors.Errorf("error creating config") + return types.ConfigCreateResponse{}, errors.New("error creating config") }, expectedError: "error creating config", }, @@ -63,7 +64,7 @@ func TestConfigCreateWithName(t *testing.T) { cli := test.NewFakeCli(&fakeClient{ configCreateFunc: func(_ context.Context, spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) { if spec.Name != name { - return types.ConfigCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name) + return types.ConfigCreateResponse{}, fmt.Errorf("expected name %q, got %q", name, spec.Name) } actual = spec.Data @@ -102,7 +103,7 @@ func TestConfigCreateWithLabels(t *testing.T) { cli := test.NewFakeCli(&fakeClient{ configCreateFunc: func(_ context.Context, spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) { if !reflect.DeepEqual(spec, expected) { - return types.ConfigCreateResponse{}, errors.Errorf("expected %+v, got %+v", expected, spec) + return types.ConfigCreateResponse{}, fmt.Errorf("expected %+v, got %+v", expected, spec) } return types.ConfigCreateResponse{ @@ -128,11 +129,11 @@ func TestConfigCreateWithTemplatingDriver(t *testing.T) { cli := test.NewFakeCli(&fakeClient{ configCreateFunc: func(_ context.Context, spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) { if spec.Name != name { - return types.ConfigCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name) + return types.ConfigCreateResponse{}, fmt.Errorf("expected name %q, got %q", name, spec.Name) } if spec.Templating.Name != expectedDriver.Name { - return types.ConfigCreateResponse{}, errors.Errorf("expected driver %v, got %v", expectedDriver, spec.Labels) + return types.ConfigCreateResponse{}, fmt.Errorf("expected driver %v, got %v", expectedDriver, spec.Labels) } return types.ConfigCreateResponse{ diff --git a/cli/command/config/inspect_test.go b/cli/command/config/inspect_test.go index fc22516fbb..a2a8e648ba 100644 --- a/cli/command/config/inspect_test.go +++ b/cli/command/config/inspect_test.go @@ -2,6 +2,7 @@ package config import ( "context" + "errors" "fmt" "io" "testing" @@ -10,7 +11,6 @@ import ( "github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test/builders" "github.com/docker/docker/api/types/swarm" - "github.com/pkg/errors" "gotest.tools/v3/assert" "gotest.tools/v3/golden" ) @@ -28,7 +28,7 @@ func TestConfigInspectErrors(t *testing.T) { { args: []string{"foo"}, configInspectFunc: func(_ context.Context, configID string) (swarm.Config, []byte, error) { - return swarm.Config{}, nil, errors.Errorf("error while inspecting the config") + return swarm.Config{}, nil, errors.New("error while inspecting the config") }, expectedError: "error while inspecting the config", }, @@ -45,7 +45,7 @@ func TestConfigInspectErrors(t *testing.T) { if configID == "foo" { return *builders.Config(builders.ConfigName("foo")), nil, nil } - return swarm.Config{}, nil, errors.Errorf("error while inspecting the config") + return swarm.Config{}, nil, errors.New("error while inspecting the config") }, expectedError: "error while inspecting the config", }, @@ -77,7 +77,7 @@ func TestConfigInspectWithoutFormat(t *testing.T) { args: []string{"foo"}, configInspectFunc: func(_ context.Context, name string) (swarm.Config, []byte, error) { if name != "foo" { - return swarm.Config{}, nil, errors.Errorf("Invalid name, expected %s, got %s", "foo", name) + return swarm.Config{}, nil, fmt.Errorf("invalid name, expected %s, got %s", "foo", name) } return *builders.Config(builders.ConfigID("ID-foo"), builders.ConfigName("foo")), nil, nil }, diff --git a/cli/command/config/ls_test.go b/cli/command/config/ls_test.go index 15658ee330..d740ef9278 100644 --- a/cli/command/config/ls_test.go +++ b/cli/command/config/ls_test.go @@ -2,6 +2,7 @@ package config import ( "context" + "errors" "io" "testing" "time" @@ -11,7 +12,6 @@ import ( "github.com/docker/cli/internal/test/builders" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" "gotest.tools/v3/golden" @@ -29,7 +29,7 @@ func TestConfigListErrors(t *testing.T) { }, { configListFunc: func(_ context.Context, options types.ConfigListOptions) ([]swarm.Config, error) { - return []swarm.Config{}, errors.Errorf("error listing configs") + return []swarm.Config{}, errors.New("error listing configs") }, expectedError: "error listing configs", }, diff --git a/cli/command/config/remove_test.go b/cli/command/config/remove_test.go index d1c5a71f9f..9213fcc11f 100644 --- a/cli/command/config/remove_test.go +++ b/cli/command/config/remove_test.go @@ -1,12 +1,12 @@ package config import ( + "errors" "io" "strings" "testing" "github.com/docker/cli/internal/test" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -24,7 +24,7 @@ func TestConfigRemoveErrors(t *testing.T) { { args: []string{"foo"}, configRemoveFunc: func(name string) error { - return errors.Errorf("error removing config") + return errors.New("error removing config") }, expectedError: "error removing config", }, @@ -66,7 +66,7 @@ func TestConfigRemoveContinueAfterError(t *testing.T) { configRemoveFunc: func(name string) error { removedConfigs = append(removedConfigs, name) if name == "foo" { - return errors.Errorf("error removing config: %s", name) + return errors.New("error removing config: " + name) } return nil }, diff --git a/cli/command/container/attach_test.go b/cli/command/container/attach_test.go index 5b0276f38c..b4ae6e9f45 100644 --- a/cli/command/container/attach_test.go +++ b/cli/command/container/attach_test.go @@ -1,13 +1,13 @@ package container import ( + "errors" "io" "testing" "github.com/docker/cli/cli" "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/container" - "github.com/pkg/errors" "gotest.tools/v3/assert" ) @@ -23,7 +23,7 @@ func TestNewAttachCommandErrors(t *testing.T) { args: []string{"5cb5bb5e4a3b"}, expectedError: "something went wrong", containerInspectFunc: func(containerID string) (container.InspectResponse, error) { - return container.InspectResponse{}, errors.Errorf("something went wrong") + return container.InspectResponse{}, errors.New("something went wrong") }, }, { diff --git a/cli/command/container/commit_test.go b/cli/command/container/commit_test.go index a9127035a2..b19d9ced4f 100644 --- a/cli/command/container/commit_test.go +++ b/cli/command/container/commit_test.go @@ -2,13 +2,13 @@ package container import ( "context" + "errors" "io" "testing" "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) diff --git a/cli/command/container/diff_test.go b/cli/command/container/diff_test.go index 2fb191fe81..fd2271e434 100644 --- a/cli/command/container/diff_test.go +++ b/cli/command/container/diff_test.go @@ -2,13 +2,13 @@ package container import ( "context" + "errors" "io" "strings" "testing" "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/container" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) diff --git a/cli/command/container/exec_test.go b/cli/command/container/exec_test.go index 89193b29f4..2d4a0ff168 100644 --- a/cli/command/container/exec_test.go +++ b/cli/command/container/exec_test.go @@ -2,6 +2,7 @@ package container import ( "context" + "errors" "io" "os" "testing" @@ -12,7 +13,6 @@ import ( "github.com/docker/cli/opts" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" "gotest.tools/v3/fs" @@ -259,7 +259,7 @@ func TestNewExecCommandErrors(t *testing.T) { args: []string{"5cb5bb5e4a3b", "-t", "-i", "bash"}, expectedError: "something went wrong", containerInspectFunc: func(containerID string) (container.InspectResponse, error) { - return container.InspectResponse{}, errors.Errorf("something went wrong") + return container.InspectResponse{}, errors.New("something went wrong") }, }, } diff --git a/cli/command/container/opts_test.go b/cli/command/container/opts_test.go index 0acb16431b..720c9dfa04 100644 --- a/cli/command/container/opts_test.go +++ b/cli/command/container/opts_test.go @@ -1,6 +1,7 @@ package container import ( + "errors" "fmt" "io" "os" @@ -12,7 +13,6 @@ import ( "github.com/docker/docker/api/types/container" networktypes "github.com/docker/docker/api/types/network" "github.com/docker/go-connections/nat" - "github.com/pkg/errors" "github.com/spf13/pflag" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -340,7 +340,7 @@ func compareRandomizedStrings(a, b, c, d string) error { if a == d && b == c { return nil } - return errors.Errorf("strings don't match") + return errors.New("strings don't match") } // Simple parse with MacAddress validation diff --git a/cli/command/container/prune_test.go b/cli/command/container/prune_test.go index 1ded0f2882..6700235c3d 100644 --- a/cli/command/container/prune_test.go +++ b/cli/command/container/prune_test.go @@ -2,13 +2,13 @@ package container import ( "context" + "errors" "io" "testing" "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" - "github.com/pkg/errors" ) func TestContainerPrunePromptTermination(t *testing.T) { diff --git a/cli/command/container/rename_test.go b/cli/command/container/rename_test.go index 4d9c3f664d..9a2cae4b3c 100644 --- a/cli/command/container/rename_test.go +++ b/cli/command/container/rename_test.go @@ -2,11 +2,11 @@ package container import ( "context" + "errors" "io" "testing" "github.com/docker/cli/internal/test" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) diff --git a/cli/command/container/restart_test.go b/cli/command/container/restart_test.go index f09323ec2a..a5cdb1cf1b 100644 --- a/cli/command/container/restart_test.go +++ b/cli/command/container/restart_test.go @@ -2,6 +2,7 @@ package container import ( "context" + "errors" "io" "sort" "sync" @@ -10,7 +11,6 @@ import ( "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/container" "github.com/docker/docker/errdefs" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) diff --git a/cli/command/container/stop_test.go b/cli/command/container/stop_test.go index 50013d4775..83a9b706f1 100644 --- a/cli/command/container/stop_test.go +++ b/cli/command/container/stop_test.go @@ -2,6 +2,7 @@ package container import ( "context" + "errors" "io" "sort" "sync" @@ -10,7 +11,6 @@ import ( "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/container" "github.com/docker/docker/errdefs" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) diff --git a/cli/command/container/tty_test.go b/cli/command/container/tty_test.go index c90d9417a7..0c4111e40d 100644 --- a/cli/command/container/tty_test.go +++ b/cli/command/container/tty_test.go @@ -2,13 +2,13 @@ package container import ( "context" + "errors" "testing" "time" "github.com/docker/cli/cli/command" "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/container" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -16,7 +16,7 @@ import ( func TestInitTtySizeErrors(t *testing.T) { expectedError := "failed to resize tty, using default size\n" fakeContainerExecResizeFunc := func(id string, options container.ResizeOptions) error { - return errors.Errorf("Error response from daemon: no such exec") + return errors.New("Error response from daemon: no such exec") } fakeResizeTtyFunc := func(ctx context.Context, cli command.Cli, id string, isExec bool) error { height, width := uint(1024), uint(768) diff --git a/cli/command/idresolver/idresolver_test.go b/cli/command/idresolver/idresolver_test.go index 1b8810c7ae..dbf2f3875f 100644 --- a/cli/command/idresolver/idresolver_test.go +++ b/cli/command/idresolver/idresolver_test.go @@ -2,11 +2,11 @@ package idresolver import ( "context" + "errors" "testing" "github.com/docker/cli/internal/test/builders" "github.com/docker/docker/api/types/swarm" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -14,7 +14,7 @@ import ( func TestResolveError(t *testing.T) { cli := &fakeClient{ nodeInspectFunc: func(nodeID string) (swarm.Node, []byte, error) { - return swarm.Node{}, []byte{}, errors.Errorf("error inspecting node") + return swarm.Node{}, []byte{}, errors.New("error inspecting node") }, } @@ -75,7 +75,7 @@ func TestResolveNode(t *testing.T) { { nodeID: "nodeID", nodeInspectFunc: func(string) (swarm.Node, []byte, error) { - return swarm.Node{}, []byte{}, errors.Errorf("error inspecting node") + return swarm.Node{}, []byte{}, errors.New("error inspecting node") }, expectedID: "nodeID", }, @@ -117,7 +117,7 @@ func TestResolveService(t *testing.T) { { serviceID: "serviceID", serviceInspectFunc: func(string) (swarm.Service, []byte, error) { - return swarm.Service{}, []byte{}, errors.Errorf("error inspecting service") + return swarm.Service{}, []byte{}, errors.New("error inspecting service") }, expectedID: "serviceID", }, diff --git a/cli/command/image/history_test.go b/cli/command/image/history_test.go index 4a406864d5..1aa91c963a 100644 --- a/cli/command/image/history_test.go +++ b/cli/command/image/history_test.go @@ -1,6 +1,7 @@ package image import ( + "errors" "fmt" "io" "testing" @@ -9,7 +10,6 @@ import ( "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/image" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" "gotest.tools/v3/golden" @@ -32,7 +32,7 @@ func TestNewHistoryCommandErrors(t *testing.T) { args: []string{"image:tag"}, expectedError: "something went wrong", imageHistoryFunc: func(img string, options image.HistoryOptions) ([]image.HistoryResponseItem, error) { - return []image.HistoryResponseItem{{}}, errors.Errorf("something went wrong") + return []image.HistoryResponseItem{{}}, errors.New("something went wrong") }, }, { diff --git a/cli/command/image/import_test.go b/cli/command/image/import_test.go index f61a80b9d3..d6d69948df 100644 --- a/cli/command/image/import_test.go +++ b/cli/command/image/import_test.go @@ -1,13 +1,13 @@ package image import ( + "errors" "io" "strings" "testing" "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/image" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -29,7 +29,7 @@ func TestNewImportCommandErrors(t *testing.T) { args: []string{"testdata/import-command-success.input.txt"}, expectedError: "something went wrong", imageImportFunc: func(source image.ImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error) { - return nil, errors.Errorf("something went wrong") + return nil, errors.New("something went wrong") }, }, } diff --git a/cli/command/image/list_test.go b/cli/command/image/list_test.go index 3129fe12ac..8b3ff715be 100644 --- a/cli/command/image/list_test.go +++ b/cli/command/image/list_test.go @@ -1,6 +1,7 @@ package image import ( + "errors" "fmt" "io" "testing" @@ -8,7 +9,6 @@ import ( "github.com/docker/cli/cli/config/configfile" "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/image" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" "gotest.tools/v3/golden" @@ -30,7 +30,7 @@ func TestNewImagesCommandErrors(t *testing.T) { name: "failed-list", expectedError: "something went wrong", imageListFunc: func(options image.ListOptions) ([]image.Summary, error) { - return []image.Summary{}, errors.Errorf("something went wrong") + return []image.Summary{}, errors.New("something went wrong") }, }, } diff --git a/cli/command/image/load_test.go b/cli/command/image/load_test.go index 87f91c6db3..f15c295efd 100644 --- a/cli/command/image/load_test.go +++ b/cli/command/image/load_test.go @@ -1,6 +1,7 @@ package image import ( + "errors" "fmt" "io" "strings" @@ -9,7 +10,6 @@ import ( "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/image" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" "gotest.tools/v3/golden" @@ -39,7 +39,7 @@ func TestNewLoadCommandErrors(t *testing.T) { args: []string{}, expectedError: "something went wrong", imageLoadFunc: func(input io.Reader, options image.LoadOptions) (image.LoadResponse, error) { - return image.LoadResponse{}, errors.Errorf("something went wrong") + return image.LoadResponse{}, errors.New("something went wrong") }, }, { diff --git a/cli/command/image/prune_test.go b/cli/command/image/prune_test.go index 8e8d3540a6..87c8d0da12 100644 --- a/cli/command/image/prune_test.go +++ b/cli/command/image/prune_test.go @@ -2,6 +2,7 @@ package image import ( "context" + "errors" "fmt" "io" "strings" @@ -11,7 +12,6 @@ import ( "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/image" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" "gotest.tools/v3/golden" @@ -34,7 +34,7 @@ func TestNewPruneCommandErrors(t *testing.T) { args: []string{"--force"}, expectedError: "something went wrong", imagesPruneFunc: func(pruneFilter filters.Args) (image.PruneReport, error) { - return image.PruneReport{}, errors.Errorf("something went wrong") + return image.PruneReport{}, errors.New("something went wrong") }, }, } diff --git a/cli/command/image/push_test.go b/cli/command/image/push_test.go index 132b0e9a5d..88415ea8e0 100644 --- a/cli/command/image/push_test.go +++ b/cli/command/image/push_test.go @@ -1,13 +1,13 @@ package image import ( + "errors" "io" "strings" "testing" "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/image" - "github.com/pkg/errors" "gotest.tools/v3/assert" ) @@ -33,7 +33,7 @@ func TestNewPushCommandErrors(t *testing.T) { args: []string{"image:repo"}, expectedError: "Failed to push", imagePushFunc: func(ref string, options image.PushOptions) (io.ReadCloser, error) { - return io.NopCloser(strings.NewReader("")), errors.Errorf("Failed to push") + return io.NopCloser(strings.NewReader("")), errors.New("Failed to push") }, }, } diff --git a/cli/command/image/remove_test.go b/cli/command/image/remove_test.go index 61a7a346f5..dc9af57f38 100644 --- a/cli/command/image/remove_test.go +++ b/cli/command/image/remove_test.go @@ -1,13 +1,13 @@ package image import ( + "errors" "fmt" "io" "testing" "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/image" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" "gotest.tools/v3/golden" @@ -47,7 +47,7 @@ func TestNewRemoveCommandErrors(t *testing.T) { expectedError: "error removing image", imageRemoveFunc: func(img string, options image.RemoveOptions) ([]image.DeleteResponse, error) { assert.Check(t, is.Equal("image1", img)) - return []image.DeleteResponse{}, errors.Errorf("error removing image") + return []image.DeleteResponse{}, errors.New("error removing image") }, }, { @@ -57,7 +57,7 @@ func TestNewRemoveCommandErrors(t *testing.T) { imageRemoveFunc: func(img string, options image.RemoveOptions) ([]image.DeleteResponse, error) { assert.Check(t, !options.Force) assert.Check(t, options.PruneChildren) - return []image.DeleteResponse{}, errors.Errorf("error removing image") + return []image.DeleteResponse{}, errors.New("error removing image") }, }, } diff --git a/cli/command/image/save_test.go b/cli/command/image/save_test.go index 34b71924a4..3bd87dbc75 100644 --- a/cli/command/image/save_test.go +++ b/cli/command/image/save_test.go @@ -1,6 +1,7 @@ package image import ( + "errors" "io" "os" "strings" @@ -9,7 +10,6 @@ import ( "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/image" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -39,7 +39,7 @@ func TestNewSaveCommandErrors(t *testing.T) { isTerminal: false, expectedError: "error saving image", imageSaveFunc: func(images []string, options image.SaveOptions) (io.ReadCloser, error) { - return io.NopCloser(strings.NewReader("")), errors.Errorf("error saving image") + return io.NopCloser(strings.NewReader("")), errors.New("error saving image") }, }, { diff --git a/cli/command/manifest/create_test.go b/cli/command/manifest/create_test.go index c87d5d09ab..41c9b134d0 100644 --- a/cli/command/manifest/create_test.go +++ b/cli/command/manifest/create_test.go @@ -2,6 +2,7 @@ package manifest import ( "context" + "errors" "io" "testing" @@ -9,7 +10,6 @@ import ( "github.com/docker/cli/cli/manifest/store" manifesttypes "github.com/docker/cli/cli/manifest/types" "github.com/docker/cli/internal/test" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" "gotest.tools/v3/golden" @@ -103,10 +103,10 @@ func TestManifestCreateNoManifest(t *testing.T) { cli.SetManifestStore(manifestStore) cli.SetRegistryClient(&fakeRegistryClient{ getManifestFunc: func(_ context.Context, ref reference.Named) (manifesttypes.ImageManifest, error) { - return manifesttypes.ImageManifest{}, errors.Errorf("No such image: %v", ref) + return manifesttypes.ImageManifest{}, errors.New("No such image: " + ref.String()) }, getManifestListFunc: func(ctx context.Context, ref reference.Named) ([]manifesttypes.ImageManifest, error) { - return nil, errors.Errorf("No such manifest: %s", ref) + return nil, errors.New("No such manifest: " + ref.String()) }, }) diff --git a/cli/command/manifest/inspect_test.go b/cli/command/manifest/inspect_test.go index 0009b41770..83d6277bdb 100644 --- a/cli/command/manifest/inspect_test.go +++ b/cli/command/manifest/inspect_test.go @@ -2,6 +2,7 @@ package manifest import ( "context" + "errors" "io" "testing" @@ -13,7 +14,6 @@ import ( "github.com/docker/distribution/manifest/schema2" "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" "gotest.tools/v3/golden" @@ -86,7 +86,7 @@ func TestInspectCommandNotFound(t *testing.T) { return types.ImageManifest{}, errors.New("missing") }, getManifestListFunc: func(ctx context.Context, ref reference.Named) ([]types.ImageManifest, error) { - return nil, errors.Errorf("No such manifest: %s", ref) + return nil, errors.New("No such manifest: " + ref.String()) }, }) diff --git a/cli/command/manifest/push_test.go b/cli/command/manifest/push_test.go index a10d5b24db..3f747cc6f8 100644 --- a/cli/command/manifest/push_test.go +++ b/cli/command/manifest/push_test.go @@ -2,6 +2,7 @@ package manifest import ( "context" + "errors" "io" "testing" @@ -9,17 +10,16 @@ import ( "github.com/docker/cli/cli/manifest/store" manifesttypes "github.com/docker/cli/cli/manifest/types" "github.com/docker/cli/internal/test" - "github.com/pkg/errors" "gotest.tools/v3/assert" ) func newFakeRegistryClient() *fakeRegistryClient { return &fakeRegistryClient{ getManifestFunc: func(_ context.Context, _ reference.Named) (manifesttypes.ImageManifest, error) { - return manifesttypes.ImageManifest{}, errors.New("") + return manifesttypes.ImageManifest{}, errors.New("unexpected error") }, getManifestListFunc: func(_ context.Context, _ reference.Named) ([]manifesttypes.ImageManifest, error) { - return nil, errors.Errorf("") + return nil, errors.New("unexpected error") }, } } diff --git a/cli/command/network/connect_test.go b/cli/command/network/connect_test.go index f51ef869ed..a64ede90b8 100644 --- a/cli/command/network/connect_test.go +++ b/cli/command/network/connect_test.go @@ -2,12 +2,12 @@ package network import ( "context" + "errors" "io" "testing" "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/network" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -24,7 +24,7 @@ func TestNetworkConnectErrors(t *testing.T) { { args: []string{"toto", "titi"}, networkConnectFunc: func(ctx context.Context, networkID, container string, config *network.EndpointSettings) error { - return errors.Errorf("error connecting network") + return errors.New("error connecting network") }, expectedError: "error connecting network", }, diff --git a/cli/command/network/create_test.go b/cli/command/network/create_test.go index 0cc682e2ed..97348c86d8 100644 --- a/cli/command/network/create_test.go +++ b/cli/command/network/create_test.go @@ -2,13 +2,13 @@ package network import ( "context" + "errors" "io" "strings" "testing" "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/network" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -26,7 +26,7 @@ func TestNetworkCreateErrors(t *testing.T) { { args: []string{"toto"}, networkCreateFunc: func(ctx context.Context, name string, createBody network.CreateOptions) (network.CreateResponse, error) { - return network.CreateResponse{}, errors.Errorf("error creating network") + return network.CreateResponse{}, errors.New("error creating network") }, expectedError: "error creating network", }, diff --git a/cli/command/network/disconnect_test.go b/cli/command/network/disconnect_test.go index bb82452a6c..c9aeea4ec7 100644 --- a/cli/command/network/disconnect_test.go +++ b/cli/command/network/disconnect_test.go @@ -2,11 +2,11 @@ package network import ( "context" + "errors" "io" "testing" "github.com/docker/cli/internal/test" - "github.com/pkg/errors" "gotest.tools/v3/assert" ) @@ -22,7 +22,7 @@ func TestNetworkDisconnectErrors(t *testing.T) { { args: []string{"toto", "titi"}, networkDisconnectFunc: func(ctx context.Context, networkID, container string, force bool) error { - return errors.Errorf("error disconnecting network") + return errors.New("error disconnecting network") }, expectedError: "error disconnecting network", }, diff --git a/cli/command/network/list_test.go b/cli/command/network/list_test.go index cc08a00096..b3d253bf4d 100644 --- a/cli/command/network/list_test.go +++ b/cli/command/network/list_test.go @@ -2,6 +2,7 @@ package network import ( "context" + "errors" "io" "testing" @@ -10,7 +11,6 @@ import ( "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/network" "github.com/google/go-cmp/cmp" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" "gotest.tools/v3/golden" @@ -23,7 +23,7 @@ func TestNetworkListErrors(t *testing.T) { }{ { networkListFunc: func(ctx context.Context, options network.ListOptions) ([]network.Summary, error) { - return []network.Summary{}, errors.Errorf("error creating network") + return []network.Summary{}, errors.New("error creating network") }, expectedError: "error creating network", }, diff --git a/cli/command/network/prune_test.go b/cli/command/network/prune_test.go index 16010d3c74..67a57e8c8a 100644 --- a/cli/command/network/prune_test.go +++ b/cli/command/network/prune_test.go @@ -2,13 +2,13 @@ package network import ( "context" + "errors" "io" "testing" "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/network" - "github.com/pkg/errors" ) func TestNetworkPrunePromptTermination(t *testing.T) { diff --git a/cli/command/network/remove_test.go b/cli/command/network/remove_test.go index 01052b0bf5..a1390d8b8d 100644 --- a/cli/command/network/remove_test.go +++ b/cli/command/network/remove_test.go @@ -2,13 +2,13 @@ package network import ( "context" + "errors" "io" "testing" "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/network" "github.com/docker/docker/errdefs" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) diff --git a/cli/command/node/demote_test.go b/cli/command/node/demote_test.go index ad7590533d..00f3988c4f 100644 --- a/cli/command/node/demote_test.go +++ b/cli/command/node/demote_test.go @@ -1,13 +1,13 @@ package node import ( + "errors" "io" "testing" "github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test/builders" "github.com/docker/docker/api/types/swarm" - "github.com/pkg/errors" "gotest.tools/v3/assert" ) @@ -24,14 +24,14 @@ func TestNodeDemoteErrors(t *testing.T) { { args: []string{"nodeID"}, nodeInspectFunc: func() (swarm.Node, []byte, error) { - return swarm.Node{}, []byte{}, errors.Errorf("error inspecting the node") + return swarm.Node{}, []byte{}, errors.New("error inspecting the node") }, expectedError: "error inspecting the node", }, { args: []string{"nodeID"}, nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error { - return errors.Errorf("error updating the node") + return errors.New("error updating the node") }, expectedError: "error updating the node", }, @@ -57,7 +57,7 @@ func TestNodeDemoteNoChange(t *testing.T) { }, nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error { if node.Role != swarm.NodeRoleWorker { - return errors.Errorf("expected role worker, got %s", node.Role) + return errors.New("expected role worker, got " + string(node.Role)) } return nil }, @@ -74,7 +74,7 @@ func TestNodeDemoteMultipleNode(t *testing.T) { }, nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error { if node.Role != swarm.NodeRoleWorker { - return errors.Errorf("expected role worker, got %s", node.Role) + return errors.New("expected role worker, got " + string(node.Role)) } return nil }, diff --git a/cli/command/node/inspect_test.go b/cli/command/node/inspect_test.go index 84a9f6bc76..a8256c6fc4 100644 --- a/cli/command/node/inspect_test.go +++ b/cli/command/node/inspect_test.go @@ -1,6 +1,7 @@ package node import ( + "errors" "fmt" "io" "testing" @@ -9,7 +10,6 @@ import ( "github.com/docker/cli/internal/test/builders" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/system" - "github.com/pkg/errors" "gotest.tools/v3/assert" "gotest.tools/v3/golden" ) @@ -28,24 +28,24 @@ func TestNodeInspectErrors(t *testing.T) { { args: []string{"self"}, infoFunc: func() (system.Info, error) { - return system.Info{}, errors.Errorf("error asking for node info") + return system.Info{}, errors.New("error asking for node info") }, expectedError: "error asking for node info", }, { args: []string{"nodeID"}, nodeInspectFunc: func() (swarm.Node, []byte, error) { - return swarm.Node{}, []byte{}, errors.Errorf("error inspecting the node") + return swarm.Node{}, []byte{}, errors.New("error inspecting the node") }, infoFunc: func() (system.Info, error) { - return system.Info{}, errors.Errorf("error asking for node info") + return system.Info{}, errors.New("error asking for node info") }, expectedError: "error inspecting the node", }, { args: []string{"self"}, nodeInspectFunc: func() (swarm.Node, []byte, error) { - return swarm.Node{}, []byte{}, errors.Errorf("error inspecting the node") + return swarm.Node{}, []byte{}, errors.New("error inspecting the node") }, infoFunc: func() (system.Info, error) { return system.Info{Swarm: swarm.Info{NodeID: "abc"}}, nil @@ -58,7 +58,7 @@ func TestNodeInspectErrors(t *testing.T) { "pretty": "true", }, infoFunc: func() (system.Info, error) { - return system.Info{}, errors.Errorf("error asking for node info") + return system.Info{}, errors.New("error asking for node info") }, expectedError: "error asking for node info", }, diff --git a/cli/command/node/list_test.go b/cli/command/node/list_test.go index 0ccf8a2d4e..adbddc6c54 100644 --- a/cli/command/node/list_test.go +++ b/cli/command/node/list_test.go @@ -1,6 +1,7 @@ package node import ( + "errors" "io" "testing" @@ -9,7 +10,6 @@ import ( "github.com/docker/cli/internal/test/builders" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/system" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" "gotest.tools/v3/golden" @@ -23,7 +23,7 @@ func TestNodeListErrorOnAPIFailure(t *testing.T) { }{ { nodeListFunc: func() ([]swarm.Node, error) { - return []swarm.Node{}, errors.Errorf("error listing nodes") + return []swarm.Node{}, errors.New("error listing nodes") }, expectedError: "error listing nodes", }, @@ -36,7 +36,7 @@ func TestNodeListErrorOnAPIFailure(t *testing.T) { }, nil }, infoFunc: func() (system.Info, error) { - return system.Info{}, errors.Errorf("error asking for node info") + return system.Info{}, errors.New("error asking for node info") }, expectedError: "error asking for node info", }, diff --git a/cli/command/node/promote_test.go b/cli/command/node/promote_test.go index bf4dce5395..0fdcb9e1f9 100644 --- a/cli/command/node/promote_test.go +++ b/cli/command/node/promote_test.go @@ -1,13 +1,13 @@ package node import ( + "errors" "io" "testing" "github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test/builders" "github.com/docker/docker/api/types/swarm" - "github.com/pkg/errors" "gotest.tools/v3/assert" ) @@ -24,14 +24,14 @@ func TestNodePromoteErrors(t *testing.T) { { args: []string{"nodeID"}, nodeInspectFunc: func() (swarm.Node, []byte, error) { - return swarm.Node{}, []byte{}, errors.Errorf("error inspecting the node") + return swarm.Node{}, []byte{}, errors.New("error inspecting the node") }, expectedError: "error inspecting the node", }, { args: []string{"nodeID"}, nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error { - return errors.Errorf("error updating the node") + return errors.New("error updating the node") }, expectedError: "error updating the node", }, @@ -57,7 +57,7 @@ func TestNodePromoteNoChange(t *testing.T) { }, nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error { if node.Role != swarm.NodeRoleManager { - return errors.Errorf("expected role manager, got %s", node.Role) + return errors.New("expected role manager, got" + string(node.Role)) } return nil }, @@ -74,7 +74,7 @@ func TestNodePromoteMultipleNode(t *testing.T) { }, nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error { if node.Role != swarm.NodeRoleManager { - return errors.Errorf("expected role manager, got %s", node.Role) + return errors.New("expected role manager, got" + string(node.Role)) } return nil }, diff --git a/cli/command/node/ps_test.go b/cli/command/node/ps_test.go index 60daac3b8c..ea1273e6a4 100644 --- a/cli/command/node/ps_test.go +++ b/cli/command/node/ps_test.go @@ -2,6 +2,7 @@ package node import ( "context" + "errors" "fmt" "io" "testing" @@ -12,7 +13,6 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/system" - "github.com/pkg/errors" "gotest.tools/v3/assert" "gotest.tools/v3/golden" ) @@ -29,21 +29,21 @@ func TestNodePsErrors(t *testing.T) { }{ { infoFunc: func() (system.Info, error) { - return system.Info{}, errors.Errorf("error asking for node info") + return system.Info{}, errors.New("error asking for node info") }, expectedError: "error asking for node info", }, { args: []string{"nodeID"}, nodeInspectFunc: func() (swarm.Node, []byte, error) { - return swarm.Node{}, []byte{}, errors.Errorf("error inspecting the node") + return swarm.Node{}, []byte{}, errors.New("error inspecting the node") }, expectedError: "error inspecting the node", }, { args: []string{"nodeID"}, taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) { - return []swarm.Task{}, errors.Errorf("error returning the task list") + return []swarm.Task{}, errors.New("error returning the task list") }, expectedError: "error returning the task list", }, diff --git a/cli/command/node/remove_test.go b/cli/command/node/remove_test.go index 44b6342826..9e672153c4 100644 --- a/cli/command/node/remove_test.go +++ b/cli/command/node/remove_test.go @@ -1,11 +1,11 @@ package node import ( + "errors" "io" "testing" "github.com/docker/cli/internal/test" - "github.com/pkg/errors" "gotest.tools/v3/assert" ) @@ -21,7 +21,7 @@ func TestNodeRemoveErrors(t *testing.T) { { args: []string{"nodeID"}, nodeRemoveFunc: func() error { - return errors.Errorf("error removing the node") + return errors.New("error removing the node") }, expectedError: "error removing the node", }, diff --git a/cli/command/node/update_test.go b/cli/command/node/update_test.go index 52e771a9ae..233d54b574 100644 --- a/cli/command/node/update_test.go +++ b/cli/command/node/update_test.go @@ -1,13 +1,14 @@ package node import ( + "errors" + "fmt" "io" "testing" "github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test/builders" "github.com/docker/docker/api/types/swarm" - "github.com/pkg/errors" "gotest.tools/v3/assert" ) @@ -29,14 +30,14 @@ func TestNodeUpdateErrors(t *testing.T) { { args: []string{"nodeID"}, nodeInspectFunc: func() (swarm.Node, []byte, error) { - return swarm.Node{}, []byte{}, errors.Errorf("error inspecting the node") + return swarm.Node{}, []byte{}, errors.New("error inspecting the node") }, expectedError: "error inspecting the node", }, { args: []string{"nodeID"}, nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error { - return errors.Errorf("error updating the node") + return errors.New("error updating the node") }, expectedError: "error updating the node", }, @@ -86,7 +87,7 @@ func TestNodeUpdate(t *testing.T) { }, nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error { if node.Role != swarm.NodeRoleManager { - return errors.Errorf("expected role manager, got %s", node.Role) + return errors.New("expected role manager, got " + string(node.Role)) } return nil }, @@ -101,7 +102,7 @@ func TestNodeUpdate(t *testing.T) { }, nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error { if node.Availability != swarm.NodeAvailabilityDrain { - return errors.Errorf("expected drain availability, got %s", node.Availability) + return errors.New("expected drain availability, got " + string(node.Availability)) } return nil }, @@ -116,7 +117,7 @@ func TestNodeUpdate(t *testing.T) { }, nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error { if _, present := node.Annotations.Labels["lbl"]; !present { - return errors.Errorf("expected 'lbl' label, got %v", node.Annotations.Labels) + return fmt.Errorf("expected 'lbl' label, got %v", node.Annotations.Labels) } return nil }, @@ -131,7 +132,7 @@ func TestNodeUpdate(t *testing.T) { }, nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error { if value, present := node.Annotations.Labels["key"]; !present || value != "value" { - return errors.Errorf("expected 'key' label to be 'value', got %v", node.Annotations.Labels) + return fmt.Errorf("expected 'key' label to be 'value', got %v", node.Annotations.Labels) } return nil }, @@ -148,7 +149,7 @@ func TestNodeUpdate(t *testing.T) { }, nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error { if len(node.Annotations.Labels) > 0 { - return errors.Errorf("expected no labels, got %v", node.Annotations.Labels) + return fmt.Errorf("expected no labels, got %v", node.Annotations.Labels) } return nil }, diff --git a/cli/command/plugin/upgrade_test.go b/cli/command/plugin/upgrade_test.go index 006998b16f..21986cdcef 100644 --- a/cli/command/plugin/upgrade_test.go +++ b/cli/command/plugin/upgrade_test.go @@ -2,12 +2,12 @@ package plugin import ( "context" + "errors" "io" "testing" "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types" - "github.com/pkg/errors" "gotest.tools/v3/golden" ) diff --git a/cli/command/secret/create_test.go b/cli/command/secret/create_test.go index 41c7b853da..884b7d771d 100644 --- a/cli/command/secret/create_test.go +++ b/cli/command/secret/create_test.go @@ -2,6 +2,8 @@ package secret import ( "context" + "errors" + "fmt" "io" "os" "path/filepath" @@ -12,7 +14,6 @@ import ( "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -36,7 +37,7 @@ func TestSecretCreateErrors(t *testing.T) { { args: []string{"name", filepath.Join("testdata", secretDataFile)}, secretCreateFunc: func(_ context.Context, secretSpec swarm.SecretSpec) (types.SecretCreateResponse, error) { - return types.SecretCreateResponse{}, errors.Errorf("error creating secret") + return types.SecretCreateResponse{}, errors.New("error creating secret") }, expectedError: "error creating secret", }, @@ -70,7 +71,7 @@ func TestSecretCreateWithName(t *testing.T) { cli := test.NewFakeCli(&fakeClient{ secretCreateFunc: func(_ context.Context, spec swarm.SecretSpec) (types.SecretCreateResponse, error) { if !reflect.DeepEqual(spec, expected) { - return types.SecretCreateResponse{}, errors.Errorf("expected %+v, got %+v", expected, spec) + return types.SecretCreateResponse{}, fmt.Errorf("expected %+v, got %+v", expected, spec) } return types.SecretCreateResponse{ ID: "ID-" + spec.Name, @@ -93,11 +94,11 @@ func TestSecretCreateWithDriver(t *testing.T) { cli := test.NewFakeCli(&fakeClient{ secretCreateFunc: func(_ context.Context, spec swarm.SecretSpec) (types.SecretCreateResponse, error) { if spec.Name != name { - return types.SecretCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name) + return types.SecretCreateResponse{}, fmt.Errorf("expected name %q, got %q", name, spec.Name) } if spec.Driver.Name != expectedDriver.Name { - return types.SecretCreateResponse{}, errors.Errorf("expected driver %v, got %v", expectedDriver, spec.Labels) + return types.SecretCreateResponse{}, fmt.Errorf("expected driver %v, got %v", expectedDriver, spec.Labels) } return types.SecretCreateResponse{ @@ -108,7 +109,7 @@ func TestSecretCreateWithDriver(t *testing.T) { cmd := newSecretCreateCommand(cli) cmd.SetArgs([]string{name}) - cmd.Flags().Set("driver", expectedDriver.Name) + assert.Check(t, cmd.Flags().Set("driver", expectedDriver.Name)) assert.NilError(t, cmd.Execute()) assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String()))) } @@ -117,16 +118,16 @@ func TestSecretCreateWithTemplatingDriver(t *testing.T) { expectedDriver := &swarm.Driver{ Name: "template-driver", } - name := "foo" + const name = "foo" cli := test.NewFakeCli(&fakeClient{ secretCreateFunc: func(_ context.Context, spec swarm.SecretSpec) (types.SecretCreateResponse, error) { if spec.Name != name { - return types.SecretCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name) + return types.SecretCreateResponse{}, fmt.Errorf("expected name %q, got %q", name, spec.Name) } if spec.Templating.Name != expectedDriver.Name { - return types.SecretCreateResponse{}, errors.Errorf("expected driver %v, got %v", expectedDriver, spec.Labels) + return types.SecretCreateResponse{}, fmt.Errorf("expected driver %v, got %v", expectedDriver, spec.Labels) } return types.SecretCreateResponse{ @@ -137,7 +138,7 @@ func TestSecretCreateWithTemplatingDriver(t *testing.T) { cmd := newSecretCreateCommand(cli) cmd.SetArgs([]string{name}) - cmd.Flags().Set("template-driver", expectedDriver.Name) + assert.Check(t, cmd.Flags().Set("template-driver", expectedDriver.Name)) assert.NilError(t, cmd.Execute()) assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String()))) } @@ -147,16 +148,16 @@ func TestSecretCreateWithLabels(t *testing.T) { "lbl1": "Label-foo", "lbl2": "Label-bar", } - name := "foo" + const name = "foo" cli := test.NewFakeCli(&fakeClient{ secretCreateFunc: func(_ context.Context, spec swarm.SecretSpec) (types.SecretCreateResponse, error) { if spec.Name != name { - return types.SecretCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name) + return types.SecretCreateResponse{}, fmt.Errorf("expected name %q, got %q", name, spec.Name) } if !reflect.DeepEqual(spec.Labels, expectedLabels) { - return types.SecretCreateResponse{}, errors.Errorf("expected labels %v, got %v", expectedLabels, spec.Labels) + return types.SecretCreateResponse{}, fmt.Errorf("expected labels %v, got %v", expectedLabels, spec.Labels) } return types.SecretCreateResponse{ @@ -167,8 +168,8 @@ func TestSecretCreateWithLabels(t *testing.T) { cmd := newSecretCreateCommand(cli) cmd.SetArgs([]string{name, filepath.Join("testdata", secretDataFile)}) - cmd.Flags().Set("label", "lbl1=Label-foo") - cmd.Flags().Set("label", "lbl2=Label-bar") + assert.Check(t, cmd.Flags().Set("label", "lbl1=Label-foo")) + assert.Check(t, cmd.Flags().Set("label", "lbl2=Label-bar")) assert.NilError(t, cmd.Execute()) assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String()))) } diff --git a/cli/command/secret/inspect_test.go b/cli/command/secret/inspect_test.go index fffe8a237f..cd44055839 100644 --- a/cli/command/secret/inspect_test.go +++ b/cli/command/secret/inspect_test.go @@ -2,6 +2,7 @@ package secret import ( "context" + "errors" "fmt" "io" "testing" @@ -10,7 +11,6 @@ import ( "github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test/builders" "github.com/docker/docker/api/types/swarm" - "github.com/pkg/errors" "gotest.tools/v3/assert" "gotest.tools/v3/golden" ) @@ -28,7 +28,7 @@ func TestSecretInspectErrors(t *testing.T) { { args: []string{"foo"}, secretInspectFunc: func(_ context.Context, secretID string) (swarm.Secret, []byte, error) { - return swarm.Secret{}, nil, errors.Errorf("error while inspecting the secret") + return swarm.Secret{}, nil, errors.New("error while inspecting the secret") }, expectedError: "error while inspecting the secret", }, @@ -45,7 +45,7 @@ func TestSecretInspectErrors(t *testing.T) { if secretID == "foo" { return *builders.Secret(builders.SecretName("foo")), nil, nil } - return swarm.Secret{}, nil, errors.Errorf("error while inspecting the secret") + return swarm.Secret{}, nil, errors.New("error while inspecting the secret") }, expectedError: "error while inspecting the secret", }, @@ -77,7 +77,7 @@ func TestSecretInspectWithoutFormat(t *testing.T) { args: []string{"foo"}, secretInspectFunc: func(_ context.Context, name string) (swarm.Secret, []byte, error) { if name != "foo" { - return swarm.Secret{}, nil, errors.Errorf("Invalid name, expected %s, got %s", "foo", name) + return swarm.Secret{}, nil, fmt.Errorf("invalid name, expected %s, got %s", "foo", name) } return *builders.Secret(builders.SecretID("ID-foo"), builders.SecretName("foo")), nil, nil }, diff --git a/cli/command/secret/ls_test.go b/cli/command/secret/ls_test.go index 161e32f2ce..50272b02cb 100644 --- a/cli/command/secret/ls_test.go +++ b/cli/command/secret/ls_test.go @@ -2,6 +2,7 @@ package secret import ( "context" + "errors" "io" "testing" "time" @@ -11,7 +12,6 @@ import ( "github.com/docker/cli/internal/test/builders" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" "gotest.tools/v3/golden" @@ -29,7 +29,7 @@ func TestSecretListErrors(t *testing.T) { }, { secretListFunc: func(_ context.Context, options types.SecretListOptions) ([]swarm.Secret, error) { - return []swarm.Secret{}, errors.Errorf("error listing secrets") + return []swarm.Secret{}, errors.New("error listing secrets") }, expectedError: "error listing secrets", }, diff --git a/cli/command/secret/remove_test.go b/cli/command/secret/remove_test.go index b5f4889a8c..ef343d9b7b 100644 --- a/cli/command/secret/remove_test.go +++ b/cli/command/secret/remove_test.go @@ -2,12 +2,12 @@ package secret import ( "context" + "errors" "io" "strings" "testing" "github.com/docker/cli/internal/test" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -25,7 +25,7 @@ func TestSecretRemoveErrors(t *testing.T) { { args: []string{"foo"}, secretRemoveFunc: func(_ context.Context, name string) error { - return errors.Errorf("error removing secret") + return errors.New("error removing secret") }, expectedError: "error removing secret", }, @@ -67,7 +67,7 @@ func TestSecretRemoveContinueAfterError(t *testing.T) { secretRemoveFunc: func(_ context.Context, name string) error { removedSecrets = append(removedSecrets, name) if name == "foo" { - return errors.Errorf("error removing secret: %s", name) + return errors.New("error removing secret: " + name) } return nil }, diff --git a/cli/command/stack/list_test.go b/cli/command/stack/list_test.go index dd4bd4940a..92afa22f69 100644 --- a/cli/command/stack/list_test.go +++ b/cli/command/stack/list_test.go @@ -1,6 +1,7 @@ package stack import ( + "errors" "io" "testing" @@ -8,7 +9,6 @@ import ( "github.com/docker/cli/internal/test/builders" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" - "github.com/pkg/errors" "gotest.tools/v3/assert" "gotest.tools/v3/golden" ) @@ -34,7 +34,7 @@ func TestListErrors(t *testing.T) { { args: []string{}, serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) { - return []swarm.Service{}, errors.Errorf("error getting services") + return []swarm.Service{}, errors.New("error getting services") }, expectedError: "error getting services", }, diff --git a/cli/command/stack/ps_test.go b/cli/command/stack/ps_test.go index 321425139c..117bdeaf8c 100644 --- a/cli/command/stack/ps_test.go +++ b/cli/command/stack/ps_test.go @@ -1,6 +1,7 @@ package stack import ( + "errors" "io" "testing" "time" @@ -10,7 +11,6 @@ import ( "github.com/docker/cli/internal/test/builders" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" "gotest.tools/v3/golden" @@ -33,7 +33,7 @@ func TestStackPsErrors(t *testing.T) { { args: []string{"foo"}, taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) { - return nil, errors.Errorf("error getting tasks") + return nil, errors.New("error getting tasks") }, expectedError: "error getting tasks", }, diff --git a/cli/command/stack/services_test.go b/cli/command/stack/services_test.go index 29f9558654..ca71ab9779 100644 --- a/cli/command/stack/services_test.go +++ b/cli/command/stack/services_test.go @@ -1,6 +1,7 @@ package stack import ( + "errors" "io" "testing" @@ -9,7 +10,6 @@ import ( "github.com/docker/cli/internal/test/builders" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" "gotest.tools/v3/golden" @@ -27,7 +27,7 @@ func TestStackServicesErrors(t *testing.T) { { args: []string{"foo"}, serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) { - return nil, errors.Errorf("error getting services") + return nil, errors.New("error getting services") }, expectedError: "error getting services", }, @@ -37,7 +37,7 @@ func TestStackServicesErrors(t *testing.T) { return []swarm.Service{*builders.Service(builders.GlobalService())}, nil }, nodeListFunc: func(options types.NodeListOptions) ([]swarm.Node, error) { - return nil, errors.Errorf("error getting nodes") + return nil, errors.New("error getting nodes") }, taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) { return []swarm.Task{*builders.Task()}, nil @@ -50,7 +50,7 @@ func TestStackServicesErrors(t *testing.T) { return []swarm.Service{*builders.Service(builders.GlobalService())}, nil }, taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) { - return nil, errors.Errorf("error getting tasks") + return nil, errors.New("error getting tasks") }, expectedError: "error getting tasks", }, diff --git a/cli/command/stack/swarm/deploy_composefile_test.go b/cli/command/stack/swarm/deploy_composefile_test.go index 0cb66e8b44..0df678a84f 100644 --- a/cli/command/stack/swarm/deploy_composefile_test.go +++ b/cli/command/stack/swarm/deploy_composefile_test.go @@ -2,11 +2,11 @@ package swarm import ( "context" + "errors" "testing" "github.com/docker/cli/internal/test/network" networktypes "github.com/docker/docker/api/types/network" - "github.com/pkg/errors" "gotest.tools/v3/assert" ) @@ -28,8 +28,8 @@ func TestValidateExternalNetworks(t *testing.T) { expectedMsg: "could not be found. You need to create a swarm-scoped network", }, { - inspectError: errors.New("Unexpected"), - expectedMsg: "Unexpected", + inspectError: errors.New("unexpected"), + expectedMsg: "unexpected", }, // FIXME(vdemeester) that doesn't work under windows, the check needs to be smarter /* @@ -49,13 +49,13 @@ func TestValidateExternalNetworks(t *testing.T) { } for _, testcase := range testcases { - fakeClient := &network.FakeClient{ + client := &network.FakeClient{ NetworkInspectFunc: func(_ context.Context, _ string, _ networktypes.InspectOptions) (networktypes.Inspect, error) { return testcase.inspectResponse, testcase.inspectError }, } networks := []string{testcase.network} - err := validateExternalNetworks(context.Background(), fakeClient, networks) + err := validateExternalNetworks(context.Background(), client, networks) if testcase.expectedMsg == "" { assert.NilError(t, err) } else { diff --git a/cli/command/swarm/init_test.go b/cli/command/swarm/init_test.go index 8a3d981b66..cd8fafac1a 100644 --- a/cli/command/swarm/init_test.go +++ b/cli/command/swarm/init_test.go @@ -1,6 +1,7 @@ package swarm import ( + "errors" "fmt" "io" "testing" @@ -8,7 +9,6 @@ import ( "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" - "github.com/pkg/errors" "gotest.tools/v3/assert" "gotest.tools/v3/golden" ) @@ -26,28 +26,28 @@ func TestSwarmInitErrorOnAPIFailure(t *testing.T) { { name: "init-failed", swarmInitFunc: func() (string, error) { - return "", errors.Errorf("error initializing the swarm") + return "", errors.New("error initializing the swarm") }, expectedError: "error initializing the swarm", }, { name: "init-failed-with-ip-choice", swarmInitFunc: func() (string, error) { - return "", errors.Errorf("could not choose an IP address to advertise") + return "", errors.New("could not choose an IP address to advertise") }, expectedError: "could not choose an IP address to advertise - specify one with --advertise-addr", }, { name: "swarm-inspect-after-init-failed", swarmInspectFunc: func() (swarm.Swarm, error) { - return swarm.Swarm{}, errors.Errorf("error inspecting the swarm") + return swarm.Swarm{}, errors.New("error inspecting the swarm") }, expectedError: "error inspecting the swarm", }, { name: "node-inspect-after-init-failed", nodeInspectFunc: func() (swarm.Node, []byte, error) { - return swarm.Node{}, []byte{}, errors.Errorf("error inspecting the node") + return swarm.Node{}, []byte{}, errors.New("error inspecting the node") }, expectedError: "error inspecting the node", }, @@ -57,7 +57,7 @@ func TestSwarmInitErrorOnAPIFailure(t *testing.T) { flagAutolock: "true", }, swarmGetUnlockKeyFunc: func() (types.SwarmUnlockKeyResponse, error) { - return types.SwarmUnlockKeyResponse{}, errors.Errorf("error getting swarm unlock key") + return types.SwarmUnlockKeyResponse{}, errors.New("error getting swarm unlock key") }, expectedError: "could not fetch unlock key: error getting swarm unlock key", }, diff --git a/cli/command/swarm/join_test.go b/cli/command/swarm/join_test.go index 53c0c08627..02ff901ac3 100644 --- a/cli/command/swarm/join_test.go +++ b/cli/command/swarm/join_test.go @@ -1,6 +1,7 @@ package swarm import ( + "errors" "io" "strings" "testing" @@ -8,7 +9,6 @@ import ( "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/system" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -34,7 +34,7 @@ func TestSwarmJoinErrors(t *testing.T) { name: "join-failed", args: []string{"remote"}, swarmJoinFunc: func() error { - return errors.Errorf("error joining the swarm") + return errors.New("error joining the swarm") }, expectedError: "error joining the swarm", }, @@ -42,7 +42,7 @@ func TestSwarmJoinErrors(t *testing.T) { name: "join-failed-on-init", args: []string{"remote"}, infoFunc: func() (system.Info, error) { - return system.Info{}, errors.Errorf("error asking for node info") + return system.Info{}, errors.New("error asking for node info") }, expectedError: "error asking for node info", }, diff --git a/cli/command/swarm/join_token_test.go b/cli/command/swarm/join_token_test.go index 0942b2b7c7..76db830b64 100644 --- a/cli/command/swarm/join_token_test.go +++ b/cli/command/swarm/join_token_test.go @@ -1,6 +1,7 @@ package swarm import ( + "errors" "fmt" "io" "testing" @@ -9,7 +10,6 @@ import ( "github.com/docker/cli/internal/test/builders" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/system" - "github.com/pkg/errors" "gotest.tools/v3/assert" "gotest.tools/v3/golden" ) @@ -43,7 +43,7 @@ func TestSwarmJoinTokenErrors(t *testing.T) { name: "swarm-inspect-failed", args: []string{"worker"}, swarmInspectFunc: func() (swarm.Swarm, error) { - return swarm.Swarm{}, errors.Errorf("error inspecting the swarm") + return swarm.Swarm{}, errors.New("error inspecting the swarm") }, expectedError: "error inspecting the swarm", }, @@ -54,7 +54,7 @@ func TestSwarmJoinTokenErrors(t *testing.T) { flagRotate: "true", }, swarmInspectFunc: func() (swarm.Swarm, error) { - return swarm.Swarm{}, errors.Errorf("error inspecting the swarm") + return swarm.Swarm{}, errors.New("error inspecting the swarm") }, expectedError: "error inspecting the swarm", }, @@ -65,7 +65,7 @@ func TestSwarmJoinTokenErrors(t *testing.T) { flagRotate: "true", }, swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error { - return errors.Errorf("error updating the swarm") + return errors.New("error updating the swarm") }, expectedError: "error updating the swarm", }, @@ -73,7 +73,7 @@ func TestSwarmJoinTokenErrors(t *testing.T) { name: "node-inspect-failed", args: []string{"worker"}, nodeInspectFunc: func() (swarm.Node, []byte, error) { - return swarm.Node{}, []byte{}, errors.Errorf("error inspecting node") + return swarm.Node{}, []byte{}, errors.New("error inspecting node") }, expectedError: "error inspecting node", }, @@ -81,7 +81,7 @@ func TestSwarmJoinTokenErrors(t *testing.T) { name: "info-failed", args: []string{"worker"}, infoFunc: func() (system.Info, error) { - return system.Info{}, errors.Errorf("error asking for node info") + return system.Info{}, errors.New("error asking for node info") }, expectedError: "error asking for node info", }, diff --git a/cli/command/swarm/leave_test.go b/cli/command/swarm/leave_test.go index b3a868b25c..19dd1dc1f6 100644 --- a/cli/command/swarm/leave_test.go +++ b/cli/command/swarm/leave_test.go @@ -1,12 +1,12 @@ package swarm import ( + "errors" "io" "strings" "testing" "github.com/docker/cli/internal/test" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -26,7 +26,7 @@ func TestSwarmLeaveErrors(t *testing.T) { { name: "leave-failed", swarmLeaveFunc: func() error { - return errors.Errorf("error leaving the swarm") + return errors.New("error leaving the swarm") }, expectedError: "error leaving the swarm", }, diff --git a/cli/command/swarm/unlock_key_test.go b/cli/command/swarm/unlock_key_test.go index 8cb403dc7f..e55567b50e 100644 --- a/cli/command/swarm/unlock_key_test.go +++ b/cli/command/swarm/unlock_key_test.go @@ -1,6 +1,7 @@ package swarm import ( + "errors" "fmt" "io" "testing" @@ -9,7 +10,6 @@ import ( "github.com/docker/cli/internal/test/builders" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" - "github.com/pkg/errors" "gotest.tools/v3/assert" "gotest.tools/v3/golden" ) @@ -35,7 +35,7 @@ func TestSwarmUnlockKeyErrors(t *testing.T) { flagRotate: "true", }, swarmInspectFunc: func() (swarm.Swarm, error) { - return swarm.Swarm{}, errors.Errorf("error inspecting the swarm") + return swarm.Swarm{}, errors.New("error inspecting the swarm") }, expectedError: "error inspecting the swarm", }, @@ -58,14 +58,14 @@ func TestSwarmUnlockKeyErrors(t *testing.T) { return *builders.Swarm(builders.Autolock()), nil }, swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error { - return errors.Errorf("error updating the swarm") + return errors.New("error updating the swarm") }, expectedError: "error updating the swarm", }, { name: "swarm-get-unlock-key-failed", swarmGetUnlockKeyFunc: func() (types.SwarmUnlockKeyResponse, error) { - return types.SwarmUnlockKeyResponse{}, errors.Errorf("error getting unlock key") + return types.SwarmUnlockKeyResponse{}, errors.New("error getting unlock key") }, expectedError: "error getting unlock key", }, @@ -88,8 +88,8 @@ func TestSwarmUnlockKeyErrors(t *testing.T) { swarmGetUnlockKeyFunc: tc.swarmGetUnlockKeyFunc, })) cmd.SetArgs(tc.args) - for key, value := range tc.flags { - assert.Check(t, cmd.Flags().Set(key, value)) + for k, v := range tc.flags { + assert.Check(t, cmd.Flags().Set(k, v)) } cmd.SetOut(io.Discard) cmd.SetErr(io.Discard) @@ -165,8 +165,8 @@ func TestSwarmUnlockKey(t *testing.T) { }) cmd := newUnlockKeyCommand(cli) cmd.SetArgs(tc.args) - for key, value := range tc.flags { - assert.Check(t, cmd.Flags().Set(key, value)) + for k, v := range tc.flags { + assert.Check(t, cmd.Flags().Set(k, v)) } assert.NilError(t, cmd.Execute()) golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("unlockkeys-%s.golden", tc.name)) diff --git a/cli/command/swarm/unlock_test.go b/cli/command/swarm/unlock_test.go index 07c3cf1d6e..f0cdfdfa8e 100644 --- a/cli/command/swarm/unlock_test.go +++ b/cli/command/swarm/unlock_test.go @@ -1,6 +1,7 @@ package swarm import ( + "errors" "io" "strings" "testing" @@ -9,7 +10,6 @@ import ( "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/system" - "github.com/pkg/errors" "gotest.tools/v3/assert" ) @@ -58,7 +58,7 @@ func TestSwarmUnlockErrors(t *testing.T) { }, nil }, swarmUnlockFunc: func(req swarm.UnlockRequest) error { - return errors.Errorf("error unlocking the swarm") + return errors.New("error unlocking the swarm") }, expectedError: "error unlocking the swarm", }, @@ -90,7 +90,7 @@ func TestSwarmUnlock(t *testing.T) { }, swarmUnlockFunc: func(req swarm.UnlockRequest) error { if req.UnlockKey != input { - return errors.Errorf("Invalid unlock key") + return errors.New("invalid unlock key") } return nil }, diff --git a/cli/command/swarm/update_test.go b/cli/command/swarm/update_test.go index 3f147f3f90..98dd0b7abe 100644 --- a/cli/command/swarm/update_test.go +++ b/cli/command/swarm/update_test.go @@ -1,6 +1,7 @@ package swarm import ( + "errors" "fmt" "io" "testing" @@ -10,7 +11,6 @@ import ( "github.com/docker/cli/internal/test/builders" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" - "github.com/pkg/errors" "gotest.tools/v3/assert" "gotest.tools/v3/golden" ) @@ -36,7 +36,7 @@ func TestSwarmUpdateErrors(t *testing.T) { flagTaskHistoryLimit: "10", }, swarmInspectFunc: func() (swarm.Swarm, error) { - return swarm.Swarm{}, errors.Errorf("error inspecting the swarm") + return swarm.Swarm{}, errors.New("error inspecting the swarm") }, expectedError: "error inspecting the swarm", }, @@ -46,7 +46,7 @@ func TestSwarmUpdateErrors(t *testing.T) { flagTaskHistoryLimit: "10", }, swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error { - return errors.Errorf("error updating the swarm") + return errors.New("error updating the swarm") }, expectedError: "error updating the swarm", }, @@ -59,7 +59,7 @@ func TestSwarmUpdateErrors(t *testing.T) { return *builders.Swarm(), nil }, swarmGetUnlockKeyFunc: func() (types.SwarmUnlockKeyResponse, error) { - return types.SwarmUnlockKeyResponse{}, errors.Errorf("error getting unlock key") + return types.SwarmUnlockKeyResponse{}, errors.New("error getting unlock key") }, expectedError: "error getting unlock key", }, @@ -114,33 +114,33 @@ func TestSwarmUpdate(t *testing.T) { }, swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error { if *swarm.Orchestration.TaskHistoryRetentionLimit != 10 { - return errors.Errorf("historyLimit not correctly set") + return errors.New("historyLimit not correctly set") } heartbeatDuration, err := time.ParseDuration("10s") if err != nil { return err } if swarm.Dispatcher.HeartbeatPeriod != heartbeatDuration { - return errors.Errorf("heartbeatPeriodLimit not correctly set") + return errors.New("heartbeatPeriodLimit not correctly set") } certExpiryDuration, err := time.ParseDuration("20s") if err != nil { return err } if swarm.CAConfig.NodeCertExpiry != certExpiryDuration { - return errors.Errorf("certExpiry not correctly set") + return errors.New("certExpiry not correctly set") } if len(swarm.CAConfig.ExternalCAs) != 1 || swarm.CAConfig.ExternalCAs[0].CACert != "trustroot" { - return errors.Errorf("externalCA not correctly set") + return errors.New("externalCA not correctly set") } if *swarm.Raft.KeepOldSnapshots != 10 { - return errors.Errorf("keepOldSnapshots not correctly set") + return errors.New("keepOldSnapshots not correctly set") } if swarm.Raft.SnapshotInterval != 100 { - return errors.Errorf("snapshotInterval not correctly set") + return errors.New("snapshotInterval not correctly set") } if !swarm.EncryptionConfig.AutoLockManagers { - return errors.Errorf("autolock not correctly set") + return errors.New("autolock not correctly set") } return nil }, @@ -153,7 +153,7 @@ func TestSwarmUpdate(t *testing.T) { }, swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error { if *swarm.Orchestration.TaskHistoryRetentionLimit != 10 { - return errors.Errorf("historyLimit not correctly set") + return errors.New("historyLimit not correctly set") } return nil }, diff --git a/cli/command/system/prune_test.go b/cli/command/system/prune_test.go index fa7294467f..5544c69ac4 100644 --- a/cli/command/system/prune_test.go +++ b/cli/command/system/prune_test.go @@ -2,6 +2,7 @@ package system import ( "context" + "errors" "io" "testing" @@ -10,7 +11,6 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/network" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) diff --git a/cli/command/utils_test.go b/cli/command/utils_test.go index 093eabed95..a940d876a1 100644 --- a/cli/command/utils_test.go +++ b/cli/command/utils_test.go @@ -4,6 +4,7 @@ import ( "bufio" "bytes" "context" + "errors" "fmt" "io" "os" @@ -17,7 +18,6 @@ import ( "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/streams" "github.com/docker/cli/internal/test" - "github.com/pkg/errors" "gotest.tools/v3/assert" ) diff --git a/cli/command/volume/create_test.go b/cli/command/volume/create_test.go index 3417fb689a..959050a28f 100644 --- a/cli/command/volume/create_test.go +++ b/cli/command/volume/create_test.go @@ -1,6 +1,8 @@ package volume import ( + "errors" + "fmt" "io" "reflect" "sort" @@ -9,7 +11,6 @@ import ( "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/volume" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -34,7 +35,7 @@ func TestVolumeCreateErrors(t *testing.T) { }, { volumeCreateFunc: func(createBody volume.CreateOptions) (volume.Volume, error) { - return volume.Volume{}, errors.Errorf("error creating volume") + return volume.Volume{}, errors.New("error creating volume") }, expectedError: "error creating volume", }, @@ -60,7 +61,7 @@ func TestVolumeCreateWithName(t *testing.T) { cli := test.NewFakeCli(&fakeClient{ volumeCreateFunc: func(body volume.CreateOptions) (volume.Volume, error) { if body.Name != name { - return volume.Volume{}, errors.Errorf("expected name %q, got %q", name, body.Name) + return volume.Volume{}, fmt.Errorf("expected name %q, got %q", name, body.Name) } return volume.Volume{ Name: body.Name, @@ -99,16 +100,16 @@ func TestVolumeCreateWithFlags(t *testing.T) { cli := test.NewFakeCli(&fakeClient{ volumeCreateFunc: func(body volume.CreateOptions) (volume.Volume, error) { if body.Name != "" { - return volume.Volume{}, errors.Errorf("expected empty name, got %q", body.Name) + return volume.Volume{}, fmt.Errorf("expected empty name, got %q", body.Name) } if body.Driver != expectedDriver { - return volume.Volume{}, errors.Errorf("expected driver %q, got %q", expectedDriver, body.Driver) + return volume.Volume{}, fmt.Errorf("expected driver %q, got %q", expectedDriver, body.Driver) } if !reflect.DeepEqual(body.DriverOpts, expectedOpts) { - return volume.Volume{}, errors.Errorf("expected drivers opts %v, got %v", expectedOpts, body.DriverOpts) + return volume.Volume{}, fmt.Errorf("expected drivers opts %v, got %v", expectedOpts, body.DriverOpts) } if !reflect.DeepEqual(body.Labels, expectedLabels) { - return volume.Volume{}, errors.Errorf("expected labels %v, got %v", expectedLabels, body.Labels) + return volume.Volume{}, fmt.Errorf("expected labels %v, got %v", expectedLabels, body.Labels) } return volume.Volume{ Name: name, diff --git a/cli/command/volume/inspect_test.go b/cli/command/volume/inspect_test.go index 624dc8de63..91cfbd3306 100644 --- a/cli/command/volume/inspect_test.go +++ b/cli/command/volume/inspect_test.go @@ -1,6 +1,7 @@ package volume import ( + "errors" "fmt" "io" "testing" @@ -9,7 +10,6 @@ import ( "github.com/docker/cli/internal/test/builders" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/volume" - "github.com/pkg/errors" "gotest.tools/v3/assert" "gotest.tools/v3/golden" ) @@ -27,7 +27,7 @@ func TestVolumeInspectErrors(t *testing.T) { { args: []string{"foo"}, volumeInspectFunc: func(volumeID string) (volume.Volume, error) { - return volume.Volume{}, errors.Errorf("error while inspecting the volume") + return volume.Volume{}, errors.New("error while inspecting the volume") }, expectedError: "error while inspecting the volume", }, @@ -46,7 +46,7 @@ func TestVolumeInspectErrors(t *testing.T) { Name: "foo", }, nil } - return volume.Volume{}, errors.Errorf("error while inspecting the volume") + return volume.Volume{}, errors.New("error while inspecting the volume") }, expectedError: "error while inspecting the volume", }, @@ -78,7 +78,7 @@ func TestVolumeInspectWithoutFormat(t *testing.T) { args: []string{"foo"}, volumeInspectFunc: func(volumeID string) (volume.Volume, error) { if volumeID != "foo" { - return volume.Volume{}, errors.Errorf("Invalid volumeID, expected %s, got %s", "foo", volumeID) + return volume.Volume{}, fmt.Errorf("invalid volumeID, expected %s, got %s", "foo", volumeID) } return *builders.Volume(), nil }, diff --git a/cli/command/volume/list_test.go b/cli/command/volume/list_test.go index 08fd403848..8b2a8f3161 100644 --- a/cli/command/volume/list_test.go +++ b/cli/command/volume/list_test.go @@ -1,6 +1,7 @@ package volume import ( + "errors" "io" "testing" @@ -9,7 +10,6 @@ import ( "github.com/docker/cli/internal/test/builders" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/volume" - "github.com/pkg/errors" "gotest.tools/v3/assert" "gotest.tools/v3/golden" ) @@ -27,7 +27,7 @@ func TestVolumeListErrors(t *testing.T) { }, { volumeListFunc: func(filter filters.Args) (volume.ListResponse, error) { - return volume.ListResponse{}, errors.Errorf("error listing volumes") + return volume.ListResponse{}, errors.New("error listing volumes") }, expectedError: "error listing volumes", }, diff --git a/cli/command/volume/prune_test.go b/cli/command/volume/prune_test.go index 8c49e22f51..11ee8adef8 100644 --- a/cli/command/volume/prune_test.go +++ b/cli/command/volume/prune_test.go @@ -2,6 +2,7 @@ package volume import ( "context" + "errors" "fmt" "io" "runtime" @@ -12,7 +13,6 @@ import ( "github.com/docker/cli/internal/test" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/volume" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" "gotest.tools/v3/golden" @@ -38,7 +38,7 @@ func TestVolumePruneErrors(t *testing.T) { "force": "true", }, volumePruneFunc: func(args filters.Args) (volume.PruneReport, error) { - return volume.PruneReport{}, errors.Errorf("error pruning volumes") + return volume.PruneReport{}, errors.New("error pruning volumes") }, expectedError: "error pruning volumes", }, diff --git a/cli/command/volume/remove_test.go b/cli/command/volume/remove_test.go index 61ac03578b..14fe2726c1 100644 --- a/cli/command/volume/remove_test.go +++ b/cli/command/volume/remove_test.go @@ -1,11 +1,11 @@ package volume import ( + "errors" "io" "testing" "github.com/docker/cli/internal/test" - "github.com/pkg/errors" "gotest.tools/v3/assert" ) @@ -21,7 +21,7 @@ func TestVolumeRemoveErrors(t *testing.T) { { args: []string{"nodeID"}, volumeRemoveFunc: func(volumeID string, force bool) error { - return errors.Errorf("error removing the volume") + return errors.New("error removing the volume") }, expectedError: "error removing the volume", }, diff --git a/cli/compose/convert/service_test.go b/cli/compose/convert/service_test.go index a7c8bf28ca..3cf58d1992 100644 --- a/cli/compose/convert/service_test.go +++ b/cli/compose/convert/service_test.go @@ -2,6 +2,7 @@ package convert import ( "context" + "errors" "os" "strings" "testing" @@ -12,7 +13,6 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/client" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) diff --git a/cli/config/credentials/native_store_test.go b/cli/config/credentials/native_store_test.go index f55d269ed5..c2f843bfbb 100644 --- a/cli/config/credentials/native_store_test.go +++ b/cli/config/credentials/native_store_test.go @@ -2,6 +2,7 @@ package credentials import ( "encoding/json" + "errors" "fmt" "io" "strings" @@ -10,7 +11,6 @@ import ( "github.com/docker/cli/cli/config/types" "github.com/docker/docker-credential-helpers/client" "github.com/docker/docker-credential-helpers/credentials" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -22,7 +22,7 @@ const ( missingCredsAddress = "https://missing.docker.io/v1" ) -var errCommandExited = errors.Errorf("exited 1") +var errCommandExited = errors.New("exited 1") // mockCommand simulates interactions between the docker client and a remote // credentials helper. diff --git a/e2e/testutils/plugins.go b/e2e/testutils/plugins.go index e194eef9a5..1485f425b1 100644 --- a/e2e/testutils/plugins.go +++ b/e2e/testutils/plugins.go @@ -13,7 +13,6 @@ import ( "testing" "github.com/docker/docker/api/types" - "github.com/pkg/errors" "gotest.tools/v3/assert" "gotest.tools/v3/fs" "gotest.tools/v3/icmd" @@ -87,7 +86,7 @@ func buildPlugin(t *testing.T, ctx context.Context) (string, error) { cmd.Env = append(os.Environ(), "CGO_ENABLED=0") if out, err := cmd.CombinedOutput(); err != nil { - return "", errors.Wrapf(err, "error building basic plugin bin: %s", string(out)) + return "", fmt.Errorf("error building basic plugin bin: %s: %w", string(out), err) } return installPath, nil diff --git a/internal/test/environment/testenv.go b/internal/test/environment/testenv.go index 7fe6880244..9c5d06db34 100644 --- a/internal/test/environment/testenv.go +++ b/internal/test/environment/testenv.go @@ -1,6 +1,7 @@ package environment import ( + "errors" "fmt" "os" "strings" @@ -8,7 +9,6 @@ import ( "time" "github.com/docker/docker/client" - "github.com/pkg/errors" "gotest.tools/v3/icmd" "gotest.tools/v3/poll" "gotest.tools/v3/skip" diff --git a/internal/test/output/output.go b/internal/test/output/output.go index 42f958790f..43eafa29e0 100644 --- a/internal/test/output/output.go +++ b/internal/test/output/output.go @@ -1,10 +1,9 @@ package output import ( + "fmt" "strings" "testing" - - "github.com/pkg/errors" ) // Assert checks output lines at specified locations @@ -30,7 +29,7 @@ func Prefix(expected string) func(string) error { if strings.HasPrefix(actual, expected) { return nil } - return errors.Errorf("expected %q to start with %q", actual, expected) + return fmt.Errorf("expected %q to start with %q", actual, expected) } } @@ -40,7 +39,7 @@ func Suffix(expected string) func(string) error { if strings.HasSuffix(actual, expected) { return nil } - return errors.Errorf("expected %q to end with %q", actual, expected) + return fmt.Errorf("expected %q to end with %q", actual, expected) } } @@ -50,7 +49,7 @@ func Contains(expected string) func(string) error { if strings.Contains(actual, expected) { return nil } - return errors.Errorf("expected %q to contain %q", actual, expected) + return fmt.Errorf("expected %q to contain %q", actual, expected) } } @@ -60,6 +59,6 @@ func Equals(expected string) func(string) error { if expected == actual { return nil } - return errors.Errorf("got %q, expected %q", actual, expected) + return fmt.Errorf("got %q, expected %q", actual, expected) } }