Move common error codes to errcode package
Several error codes are generally useful but tied to the v2 specification definitions. This change moves these error code definitions into the common package for use by the health package, which is not tied to the v2 API. Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
@@ -124,7 +124,7 @@ var (
|
||||
},
|
||||
},
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
ErrorCodeUnauthorized,
|
||||
errcode.ErrorCodeUnauthorized,
|
||||
},
|
||||
Body: BodyDescriptor{
|
||||
ContentType: "application/json; charset=utf-8",
|
||||
@@ -145,7 +145,7 @@ var (
|
||||
},
|
||||
},
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
ErrorCodeUnauthorized,
|
||||
errcode.ErrorCodeUnauthorized,
|
||||
},
|
||||
Body: BodyDescriptor{
|
||||
ContentType: "application/json; charset=utf-8",
|
||||
@@ -374,7 +374,7 @@ var routeDescriptors = []RouteDescriptor{
|
||||
Format: errorsBody,
|
||||
},
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
ErrorCodeUnauthorized,
|
||||
errcode.ErrorCodeUnauthorized,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -451,7 +451,7 @@ var routeDescriptors = []RouteDescriptor{
|
||||
Format: errorsBody,
|
||||
},
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
ErrorCodeUnauthorized,
|
||||
errcode.ErrorCodeUnauthorized,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -506,7 +506,7 @@ var routeDescriptors = []RouteDescriptor{
|
||||
Format: errorsBody,
|
||||
},
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
ErrorCodeUnauthorized,
|
||||
errcode.ErrorCodeUnauthorized,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -568,7 +568,7 @@ var routeDescriptors = []RouteDescriptor{
|
||||
Format: errorsBody,
|
||||
},
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
ErrorCodeUnauthorized,
|
||||
errcode.ErrorCodeUnauthorized,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -645,7 +645,7 @@ var routeDescriptors = []RouteDescriptor{
|
||||
Format: errorsBody,
|
||||
},
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
ErrorCodeUnauthorized,
|
||||
errcode.ErrorCodeUnauthorized,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -682,7 +682,7 @@ var routeDescriptors = []RouteDescriptor{
|
||||
},
|
||||
},
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
ErrorCodeUnauthorized,
|
||||
errcode.ErrorCodeUnauthorized,
|
||||
},
|
||||
Body: BodyDescriptor{
|
||||
ContentType: "application/json; charset=utf-8",
|
||||
@@ -737,7 +737,7 @@ var routeDescriptors = []RouteDescriptor{
|
||||
},
|
||||
},
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
ErrorCodeUnauthorized,
|
||||
errcode.ErrorCodeUnauthorized,
|
||||
},
|
||||
Body: BodyDescriptor{
|
||||
ContentType: "application/json; charset=utf-8",
|
||||
@@ -974,7 +974,7 @@ var routeDescriptors = []RouteDescriptor{
|
||||
Format: errorsBody,
|
||||
},
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
ErrorCodeUnsupported,
|
||||
errcode.ErrorCodeUnsupported,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@@ -9,24 +9,6 @@ import (
|
||||
const errGroup = "registry.api.v2"
|
||||
|
||||
var (
|
||||
// ErrorCodeUnsupported is returned when an operation is not supported.
|
||||
ErrorCodeUnsupported = errcode.Register(errGroup, errcode.ErrorDescriptor{
|
||||
Value: "UNSUPPORTED",
|
||||
Message: "The operation is unsupported.",
|
||||
Description: `The operation was unsupported due to a missing
|
||||
implementation or invalid set of parameters.`,
|
||||
})
|
||||
|
||||
// ErrorCodeUnauthorized is returned if a request is not authorized.
|
||||
ErrorCodeUnauthorized = errcode.Register(errGroup, errcode.ErrorDescriptor{
|
||||
Value: "UNAUTHORIZED",
|
||||
Message: "access to the requested resource is not authorized",
|
||||
Description: `The access controller denied access for the operation on
|
||||
a resource. Often this will be accompanied by a 401 Unauthorized
|
||||
response status.`,
|
||||
HTTPStatusCode: http.StatusUnauthorized,
|
||||
})
|
||||
|
||||
// ErrorCodeDigestInvalid is returned when uploading a blob if the
|
||||
// provided digest does not match the blob contents.
|
||||
ErrorCodeDigestInvalid = errcode.Register(errGroup, errcode.ErrorDescriptor{
|
||||
|
Reference in New Issue
Block a user