diff --git a/client/image_build_test.go b/client/image_build_test.go index da854a4968..e7b7388a1f 100644 --- a/client/image_build_test.go +++ b/client/image_build_test.go @@ -10,10 +10,10 @@ import ( "strings" "testing" + cerrdefs "github.com/containerd/errdefs" "github.com/docker/docker/api/types/build" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/registry" - "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -23,7 +23,7 @@ func TestImageBuildError(t *testing.T) { client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } _, err := client.ImageBuild(context.Background(), nil, build.ImageBuildOptions{}) - assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) + assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) } func TestImageBuild(t *testing.T) { diff --git a/client/image_create_test.go b/client/image_create_test.go index 5a8cdf5d24..ba8535e6be 100644 --- a/client/image_create_test.go +++ b/client/image_create_test.go @@ -9,9 +9,9 @@ import ( "strings" "testing" + cerrdefs "github.com/containerd/errdefs" "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/registry" - "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -21,7 +21,7 @@ func TestImageCreateError(t *testing.T) { client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } _, err := client.ImageCreate(context.Background(), "reference", image.CreateOptions{}) - assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) + assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) } func TestImageCreate(t *testing.T) { diff --git a/client/image_history_test.go b/client/image_history_test.go index c5ae91491c..1b51807a0c 100644 --- a/client/image_history_test.go +++ b/client/image_history_test.go @@ -7,8 +7,8 @@ import ( "strings" "testing" + cerrdefs "github.com/containerd/errdefs" "github.com/docker/docker/api/types/image" - "github.com/docker/docker/errdefs" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -19,7 +19,7 @@ func TestImageHistoryError(t *testing.T) { client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } _, err := client.ImageHistory(context.Background(), "nothing") - assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) + assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) } func TestImageHistory(t *testing.T) { diff --git a/client/image_import_test.go b/client/image_import_test.go index ac6abdbec1..8637c766a0 100644 --- a/client/image_import_test.go +++ b/client/image_import_test.go @@ -9,8 +9,8 @@ import ( "strings" "testing" + cerrdefs "github.com/containerd/errdefs" "github.com/docker/docker/api/types/image" - "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -20,7 +20,7 @@ func TestImageImportError(t *testing.T) { client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } _, err := client.ImageImport(context.Background(), image.ImportSource{}, "image:tag", image.ImportOptions{}) - assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) + assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) } func TestImageImport(t *testing.T) { diff --git a/client/image_inspect_test.go b/client/image_inspect_test.go index 0746c755aa..137c69fa78 100644 --- a/client/image_inspect_test.go +++ b/client/image_inspect_test.go @@ -11,8 +11,8 @@ import ( "strings" "testing" + cerrdefs "github.com/containerd/errdefs" "github.com/docker/docker/api/types/image" - "github.com/docker/docker/errdefs" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -24,7 +24,7 @@ func TestImageInspectError(t *testing.T) { } _, err := client.ImageInspect(context.Background(), "nothing") - assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) + assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) } func TestImageInspectImageNotFound(t *testing.T) { @@ -33,7 +33,7 @@ func TestImageInspectImageNotFound(t *testing.T) { } _, err := client.ImageInspect(context.Background(), "unknown") - assert.Check(t, is.ErrorType(err, errdefs.IsNotFound)) + assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound)) } func TestImageInspectWithEmptyID(t *testing.T) { @@ -43,7 +43,7 @@ func TestImageInspectWithEmptyID(t *testing.T) { }), } _, err := client.ImageInspect(context.Background(), "") - assert.Check(t, is.ErrorType(err, errdefs.IsNotFound)) + assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound)) } func TestImageInspect(t *testing.T) { diff --git a/client/image_list_test.go b/client/image_list_test.go index c35ddd67a9..ddb38402c3 100644 --- a/client/image_list_test.go +++ b/client/image_list_test.go @@ -11,9 +11,9 @@ import ( "strings" "testing" + cerrdefs "github.com/containerd/errdefs" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/image" - "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -24,7 +24,7 @@ func TestImageListError(t *testing.T) { } _, err := client.ImageList(context.Background(), image.ListOptions{}) - assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) + assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) } // TestImageListConnectionError verifies that connection errors occurring diff --git a/client/image_load_test.go b/client/image_load_test.go index 71a43085de..d1c6d1cf13 100644 --- a/client/image_load_test.go +++ b/client/image_load_test.go @@ -8,7 +8,7 @@ import ( "net/url" "testing" - "github.com/docker/docker/errdefs" + cerrdefs "github.com/containerd/errdefs" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -20,7 +20,7 @@ func TestImageLoadError(t *testing.T) { } _, err := client.ImageLoad(context.Background(), nil, ImageLoadWithQuiet(true)) - assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) + assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) } func TestImageLoad(t *testing.T) { diff --git a/client/image_prune_test.go b/client/image_prune_test.go index 606a038f49..9fa56949dd 100644 --- a/client/image_prune_test.go +++ b/client/image_prune_test.go @@ -10,8 +10,8 @@ import ( "strings" "testing" + cerrdefs "github.com/containerd/errdefs" "github.com/docker/docker/api/types/image" - "github.com/docker/docker/errdefs" "github.com/docker/docker/api/types/filters" "gotest.tools/v3/assert" @@ -25,7 +25,7 @@ func TestImagesPruneError(t *testing.T) { } _, err := client.ImagesPrune(context.Background(), filters.NewArgs()) - assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) + assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) } func TestImagesPrune(t *testing.T) { diff --git a/client/image_pull.go b/client/image_pull.go index f5fe85dd47..ae8c807f77 100644 --- a/client/image_pull.go +++ b/client/image_pull.go @@ -6,9 +6,9 @@ import ( "net/url" "strings" + cerrdefs "github.com/containerd/errdefs" "github.com/distribution/reference" "github.com/docker/docker/api/types/image" - "github.com/docker/docker/errdefs" ) // ImagePull requests the docker host to pull an image from a remote registry. @@ -35,7 +35,7 @@ func (cli *Client) ImagePull(ctx context.Context, refStr string, options image.P } resp, err := cli.tryImageCreate(ctx, query, options.RegistryAuth) - if errdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil { + if cerrdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil { newAuthHeader, privilegeErr := options.PrivilegeFunc(ctx) if privilegeErr != nil { return nil, privilegeErr diff --git a/client/image_pull_test.go b/client/image_pull_test.go index 3a8fb6d4c9..6ff35b66ce 100644 --- a/client/image_pull_test.go +++ b/client/image_pull_test.go @@ -9,9 +9,9 @@ import ( "strings" "testing" + cerrdefs "github.com/containerd/errdefs" "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/registry" - "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -32,7 +32,7 @@ func TestImagePullAnyError(t *testing.T) { client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } _, err := client.ImagePull(context.Background(), "myimage", image.PullOptions{}) - assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) + assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) } func TestImagePullStatusUnauthorizedError(t *testing.T) { @@ -40,7 +40,7 @@ func TestImagePullStatusUnauthorizedError(t *testing.T) { client: newMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")), } _, err := client.ImagePull(context.Background(), "myimage", image.PullOptions{}) - assert.Check(t, is.ErrorType(err, errdefs.IsUnauthorized)) + assert.Check(t, is.ErrorType(err, cerrdefs.IsUnauthorized)) } func TestImagePullWithUnauthorizedErrorAndPrivilegeFuncError(t *testing.T) { @@ -66,7 +66,7 @@ func TestImagePullWithUnauthorizedErrorAndAnotherUnauthorizedError(t *testing.T) _, err := client.ImagePull(context.Background(), "myimage", image.PullOptions{ PrivilegeFunc: privilegeFunc, }) - assert.Check(t, is.ErrorType(err, errdefs.IsUnauthorized)) + assert.Check(t, is.ErrorType(err, cerrdefs.IsUnauthorized)) } func TestImagePullWithPrivilegedFuncNoError(t *testing.T) { diff --git a/client/image_push.go b/client/image_push.go index 1a343f43f1..5210304403 100644 --- a/client/image_push.go +++ b/client/image_push.go @@ -9,10 +9,10 @@ import ( "net/http" "net/url" + cerrdefs "github.com/containerd/errdefs" "github.com/distribution/reference" "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/registry" - "github.com/docker/docker/errdefs" ) // ImagePush requests the docker host to push an image to a remote registry. @@ -52,7 +52,7 @@ func (cli *Client) ImagePush(ctx context.Context, image string, options image.Pu } resp, err := cli.tryImagePush(ctx, ref.Name(), query, options.RegistryAuth) - if errdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil { + if cerrdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil { newAuthHeader, privilegeErr := options.PrivilegeFunc(ctx) if privilegeErr != nil { return nil, privilegeErr diff --git a/client/image_push_test.go b/client/image_push_test.go index 43c6b8c645..f6c13da7a8 100644 --- a/client/image_push_test.go +++ b/client/image_push_test.go @@ -9,9 +9,9 @@ import ( "strings" "testing" + cerrdefs "github.com/containerd/errdefs" "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/registry" - "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -35,7 +35,7 @@ func TestImagePushAnyError(t *testing.T) { client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } _, err := client.ImagePush(context.Background(), "myimage", image.PushOptions{}) - assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) + assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) } func TestImagePushStatusUnauthorizedError(t *testing.T) { @@ -43,7 +43,7 @@ func TestImagePushStatusUnauthorizedError(t *testing.T) { client: newMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")), } _, err := client.ImagePush(context.Background(), "myimage", image.PushOptions{}) - assert.Check(t, is.ErrorType(err, errdefs.IsUnauthorized)) + assert.Check(t, is.ErrorType(err, cerrdefs.IsUnauthorized)) } func TestImagePushWithUnauthorizedErrorAndPrivilegeFuncError(t *testing.T) { @@ -69,7 +69,7 @@ func TestImagePushWithUnauthorizedErrorAndAnotherUnauthorizedError(t *testing.T) _, err := client.ImagePush(context.Background(), "myimage", image.PushOptions{ PrivilegeFunc: privilegeFunc, }) - assert.Check(t, is.ErrorType(err, errdefs.IsUnauthorized)) + assert.Check(t, is.ErrorType(err, cerrdefs.IsUnauthorized)) } func TestImagePushWithPrivilegedFuncNoError(t *testing.T) { diff --git a/client/image_remove_test.go b/client/image_remove_test.go index 33568836d1..9d9c01b5c2 100644 --- a/client/image_remove_test.go +++ b/client/image_remove_test.go @@ -10,8 +10,8 @@ import ( "strings" "testing" + cerrdefs "github.com/containerd/errdefs" "github.com/docker/docker/api/types/image" - "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -22,7 +22,7 @@ func TestImageRemoveError(t *testing.T) { } _, err := client.ImageRemove(context.Background(), "image_id", image.RemoveOptions{}) - assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) + assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) } func TestImageRemoveImageNotFound(t *testing.T) { @@ -32,7 +32,7 @@ func TestImageRemoveImageNotFound(t *testing.T) { _, err := client.ImageRemove(context.Background(), "unknown", image.RemoveOptions{}) assert.Check(t, is.ErrorContains(err, "no such image: unknown")) - assert.Check(t, is.ErrorType(err, errdefs.IsNotFound)) + assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound)) } func TestImageRemove(t *testing.T) { diff --git a/client/image_save_test.go b/client/image_save_test.go index 2975c4085d..204c4d3989 100644 --- a/client/image_save_test.go +++ b/client/image_save_test.go @@ -8,7 +8,7 @@ import ( "net/url" "testing" - "github.com/docker/docker/errdefs" + cerrdefs "github.com/containerd/errdefs" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -20,7 +20,7 @@ func TestImageSaveError(t *testing.T) { } armv64 := ocispec.Platform{Architecture: "arm64", OS: "linux", Variant: "v8"} _, err := client.ImageSave(context.Background(), []string{"nothing"}, ImageSaveWithPlatforms(armv64)) - assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) + assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) } func TestImageSave(t *testing.T) { diff --git a/client/image_search.go b/client/image_search.go index 0a7b5ec226..f3aab43a80 100644 --- a/client/image_search.go +++ b/client/image_search.go @@ -7,9 +7,9 @@ import ( "net/url" "strconv" + cerrdefs "github.com/containerd/errdefs" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/registry" - "github.com/docker/docker/errdefs" ) // ImageSearch makes the docker host search by a term in a remote registry. @@ -32,7 +32,7 @@ func (cli *Client) ImageSearch(ctx context.Context, term string, options registr resp, err := cli.tryImageSearch(ctx, query, options.RegistryAuth) defer ensureReaderClosed(resp) - if errdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil { + if cerrdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil { newAuthHeader, privilegeErr := options.PrivilegeFunc(ctx) if privilegeErr != nil { return results, privilegeErr diff --git a/client/image_search_test.go b/client/image_search_test.go index 61694da796..8ae9b40ba6 100644 --- a/client/image_search_test.go +++ b/client/image_search_test.go @@ -10,9 +10,9 @@ import ( "strings" "testing" + cerrdefs "github.com/containerd/errdefs" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/registry" - "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -22,7 +22,7 @@ func TestImageSearchAnyError(t *testing.T) { client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } _, err := client.ImageSearch(context.Background(), "some-image", registry.SearchOptions{}) - assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) + assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) } func TestImageSearchStatusUnauthorizedError(t *testing.T) { @@ -30,7 +30,7 @@ func TestImageSearchStatusUnauthorizedError(t *testing.T) { client: newMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")), } _, err := client.ImageSearch(context.Background(), "some-image", registry.SearchOptions{}) - assert.Check(t, is.ErrorType(err, errdefs.IsUnauthorized)) + assert.Check(t, is.ErrorType(err, cerrdefs.IsUnauthorized)) } func TestImageSearchWithUnauthorizedErrorAndPrivilegeFuncError(t *testing.T) { @@ -56,7 +56,7 @@ func TestImageSearchWithUnauthorizedErrorAndAnotherUnauthorizedError(t *testing. _, err := client.ImageSearch(context.Background(), "some-image", registry.SearchOptions{ PrivilegeFunc: privilegeFunc, }) - assert.Check(t, is.ErrorType(err, errdefs.IsUnauthorized)) + assert.Check(t, is.ErrorType(err, cerrdefs.IsUnauthorized)) } func TestImageSearchWithPrivilegedFuncNoError(t *testing.T) { diff --git a/client/image_tag_test.go b/client/image_tag_test.go index 28270d32de..173477f746 100644 --- a/client/image_tag_test.go +++ b/client/image_tag_test.go @@ -9,7 +9,7 @@ import ( "strings" "testing" - "github.com/docker/docker/errdefs" + cerrdefs "github.com/containerd/errdefs" "github.com/docker/docker/testutil" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -21,7 +21,7 @@ func TestImageTagError(t *testing.T) { } err := client.ImageTag(context.Background(), "image_id", "repo:tag") - assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) + assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) } // Note: this is not testing all the InvalidReference as it's the responsibility