mirror of
https://github.com/rancher/os.git
synced 2025-09-01 06:40:31 +00:00
migrate to upstream libcompose in one and a half go
This commit is contained in:
58
vendor/github.com/docker/distribution/registry/api/errcode/register.go
generated
vendored
58
vendor/github.com/docker/distribution/registry/api/errcode/register.go
generated
vendored
@@ -13,15 +13,57 @@ var (
|
||||
groupToDescriptors = map[string][]ErrorDescriptor{}
|
||||
)
|
||||
|
||||
// ErrorCodeUnknown is a generic error that can be used as a last
|
||||
// resort if there is no situation-specific error message that can be used
|
||||
var ErrorCodeUnknown = Register("errcode", ErrorDescriptor{
|
||||
Value: "UNKNOWN",
|
||||
Message: "unknown error",
|
||||
Description: `Generic error returned when the error does not have an
|
||||
var (
|
||||
// ErrorCodeUnknown is a generic error that can be used as a last
|
||||
// resort if there is no situation-specific error message that can be used
|
||||
ErrorCodeUnknown = Register("errcode", ErrorDescriptor{
|
||||
Value: "UNKNOWN",
|
||||
Message: "unknown error",
|
||||
Description: `Generic error returned when the error does not have an
|
||||
API classification.`,
|
||||
HTTPStatusCode: http.StatusInternalServerError,
|
||||
})
|
||||
HTTPStatusCode: http.StatusInternalServerError,
|
||||
})
|
||||
|
||||
// ErrorCodeUnsupported is returned when an operation is not supported.
|
||||
ErrorCodeUnsupported = Register("errcode", ErrorDescriptor{
|
||||
Value: "UNSUPPORTED",
|
||||
Message: "The operation is unsupported.",
|
||||
Description: `The operation was unsupported due to a missing
|
||||
implementation or invalid set of parameters.`,
|
||||
HTTPStatusCode: http.StatusMethodNotAllowed,
|
||||
})
|
||||
|
||||
// ErrorCodeUnauthorized is returned if a request requires
|
||||
// authentication.
|
||||
ErrorCodeUnauthorized = Register("errcode", ErrorDescriptor{
|
||||
Value: "UNAUTHORIZED",
|
||||
Message: "authentication required",
|
||||
Description: `The access controller was unable to authenticate
|
||||
the client. Often this will be accompanied by a
|
||||
Www-Authenticate HTTP response header indicating how to
|
||||
authenticate.`,
|
||||
HTTPStatusCode: http.StatusUnauthorized,
|
||||
})
|
||||
|
||||
// ErrorCodeDenied is returned if a client does not have sufficient
|
||||
// permission to perform an action.
|
||||
ErrorCodeDenied = Register("errcode", ErrorDescriptor{
|
||||
Value: "DENIED",
|
||||
Message: "requested access to the resource is denied",
|
||||
Description: `The access controller denied access for the
|
||||
operation on a resource.`,
|
||||
HTTPStatusCode: http.StatusForbidden,
|
||||
})
|
||||
|
||||
// ErrorCodeUnavailable provides a common error to report unavialability
|
||||
// of a service or endpoint.
|
||||
ErrorCodeUnavailable = Register("errcode", ErrorDescriptor{
|
||||
Value: "UNAVAILABLE",
|
||||
Message: "service unavailable",
|
||||
Description: "Returned when a service is not available",
|
||||
HTTPStatusCode: http.StatusServiceUnavailable,
|
||||
})
|
||||
)
|
||||
|
||||
var nextCode = 1000
|
||||
var registerLock sync.Mutex
|
||||
|
273
vendor/github.com/docker/distribution/registry/api/v2/descriptors.go
generated
vendored
273
vendor/github.com/docker/distribution/registry/api/v2/descriptors.go
generated
vendored
@@ -5,6 +5,7 @@ import (
|
||||
"regexp"
|
||||
|
||||
"github.com/docker/distribution/digest"
|
||||
"github.com/docker/distribution/reference"
|
||||
"github.com/docker/distribution/registry/api/errcode"
|
||||
)
|
||||
|
||||
@@ -12,7 +13,7 @@ var (
|
||||
nameParameterDescriptor = ParameterDescriptor{
|
||||
Name: "name",
|
||||
Type: "string",
|
||||
Format: RepositoryNameRegexp.String(),
|
||||
Format: reference.NameRegexp.String(),
|
||||
Required: true,
|
||||
Description: `Name of the target repository.`,
|
||||
}
|
||||
@@ -20,7 +21,7 @@ var (
|
||||
referenceParameterDescriptor = ParameterDescriptor{
|
||||
Name: "reference",
|
||||
Type: "string",
|
||||
Format: TagNameRegexp.String(),
|
||||
Format: reference.TagRegexp.String(),
|
||||
Required: true,
|
||||
Description: `Tag or digest of the target manifest.`,
|
||||
}
|
||||
@@ -111,45 +112,67 @@ var (
|
||||
},
|
||||
}
|
||||
|
||||
unauthorizedResponse = ResponseDescriptor{
|
||||
Description: "The client does not have access to the repository.",
|
||||
unauthorizedResponseDescriptor = ResponseDescriptor{
|
||||
Name: "Authentication Required",
|
||||
StatusCode: http.StatusUnauthorized,
|
||||
Description: "The client is not authenticated.",
|
||||
Headers: []ParameterDescriptor{
|
||||
authChallengeHeader,
|
||||
{
|
||||
Name: "Content-Length",
|
||||
Type: "integer",
|
||||
Description: "Length of the JSON error response body.",
|
||||
Description: "Length of the JSON response body.",
|
||||
Format: "<length>",
|
||||
},
|
||||
},
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
ErrorCodeUnauthorized,
|
||||
},
|
||||
Body: BodyDescriptor{
|
||||
ContentType: "application/json; charset=utf-8",
|
||||
Format: unauthorizedErrorsBody,
|
||||
Format: errorsBody,
|
||||
},
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
errcode.ErrorCodeUnauthorized,
|
||||
},
|
||||
}
|
||||
|
||||
unauthorizedResponsePush = ResponseDescriptor{
|
||||
Description: "The client does not have access to push to the repository.",
|
||||
StatusCode: http.StatusUnauthorized,
|
||||
repositoryNotFoundResponseDescriptor = ResponseDescriptor{
|
||||
Name: "No Such Repository Error",
|
||||
StatusCode: http.StatusNotFound,
|
||||
Description: "The repository is not known to the registry.",
|
||||
Headers: []ParameterDescriptor{
|
||||
authChallengeHeader,
|
||||
{
|
||||
Name: "Content-Length",
|
||||
Type: "integer",
|
||||
Description: "Length of the JSON error response body.",
|
||||
Description: "Length of the JSON response body.",
|
||||
Format: "<length>",
|
||||
},
|
||||
},
|
||||
Body: BodyDescriptor{
|
||||
ContentType: "application/json; charset=utf-8",
|
||||
Format: errorsBody,
|
||||
},
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
ErrorCodeUnauthorized,
|
||||
ErrorCodeNameUnknown,
|
||||
},
|
||||
}
|
||||
|
||||
deniedResponseDescriptor = ResponseDescriptor{
|
||||
Name: "Access Denied",
|
||||
StatusCode: http.StatusForbidden,
|
||||
Description: "The client does not have required access to the repository.",
|
||||
Headers: []ParameterDescriptor{
|
||||
{
|
||||
Name: "Content-Length",
|
||||
Type: "integer",
|
||||
Description: "Length of the JSON response body.",
|
||||
Format: "<length>",
|
||||
},
|
||||
},
|
||||
Body: BodyDescriptor{
|
||||
ContentType: "application/json; charset=utf-8",
|
||||
Format: unauthorizedErrorsBody,
|
||||
Format: errorsBody,
|
||||
},
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
errcode.ErrorCodeDenied,
|
||||
},
|
||||
}
|
||||
)
|
||||
@@ -345,7 +368,7 @@ var routeDescriptors = []RouteDescriptor{
|
||||
Name: RouteNameBase,
|
||||
Path: "/v2/",
|
||||
Entity: "Base",
|
||||
Description: `Base V2 API route. Typically, this can be used for lightweight version checks and to validate registry authorization.`,
|
||||
Description: `Base V2 API route. Typically, this can be used for lightweight version checks and to validate registry authentication.`,
|
||||
Methods: []MethodDescriptor{
|
||||
{
|
||||
Method: "GET",
|
||||
@@ -363,24 +386,11 @@ var routeDescriptors = []RouteDescriptor{
|
||||
},
|
||||
},
|
||||
Failures: []ResponseDescriptor{
|
||||
{
|
||||
Description: "The client is not authorized to access the registry.",
|
||||
StatusCode: http.StatusUnauthorized,
|
||||
Headers: []ParameterDescriptor{
|
||||
authChallengeHeader,
|
||||
},
|
||||
Body: BodyDescriptor{
|
||||
ContentType: "application/json; charset=utf-8",
|
||||
Format: errorsBody,
|
||||
},
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
ErrorCodeUnauthorized,
|
||||
},
|
||||
},
|
||||
{
|
||||
Description: "The registry does not implement the V2 API.",
|
||||
StatusCode: http.StatusNotFound,
|
||||
},
|
||||
unauthorizedResponseDescriptor,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -389,7 +399,7 @@ var routeDescriptors = []RouteDescriptor{
|
||||
},
|
||||
{
|
||||
Name: RouteNameTags,
|
||||
Path: "/v2/{name:" + RepositoryNameRegexp.String() + "}/tags/list",
|
||||
Path: "/v2/{name:" + reference.NameRegexp.String() + "}/tags/list",
|
||||
Entity: "Tags",
|
||||
Description: "Retrieve information about tags.",
|
||||
Methods: []MethodDescriptor{
|
||||
@@ -432,28 +442,9 @@ var routeDescriptors = []RouteDescriptor{
|
||||
},
|
||||
},
|
||||
Failures: []ResponseDescriptor{
|
||||
{
|
||||
StatusCode: http.StatusNotFound,
|
||||
Description: "The repository is not known to the registry.",
|
||||
Body: BodyDescriptor{
|
||||
ContentType: "application/json; charset=utf-8",
|
||||
Format: errorsBody,
|
||||
},
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
ErrorCodeNameUnknown,
|
||||
},
|
||||
},
|
||||
{
|
||||
StatusCode: http.StatusUnauthorized,
|
||||
Description: "The client does not have access to the repository.",
|
||||
Body: BodyDescriptor{
|
||||
ContentType: "application/json; charset=utf-8",
|
||||
Format: errorsBody,
|
||||
},
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
ErrorCodeUnauthorized,
|
||||
},
|
||||
},
|
||||
unauthorizedResponseDescriptor,
|
||||
repositoryNotFoundResponseDescriptor,
|
||||
deniedResponseDescriptor,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -487,28 +478,9 @@ var routeDescriptors = []RouteDescriptor{
|
||||
},
|
||||
},
|
||||
Failures: []ResponseDescriptor{
|
||||
{
|
||||
StatusCode: http.StatusNotFound,
|
||||
Description: "The repository is not known to the registry.",
|
||||
Body: BodyDescriptor{
|
||||
ContentType: "application/json; charset=utf-8",
|
||||
Format: errorsBody,
|
||||
},
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
ErrorCodeNameUnknown,
|
||||
},
|
||||
},
|
||||
{
|
||||
StatusCode: http.StatusUnauthorized,
|
||||
Description: "The client does not have access to the repository.",
|
||||
Body: BodyDescriptor{
|
||||
ContentType: "application/json; charset=utf-8",
|
||||
Format: errorsBody,
|
||||
},
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
ErrorCodeUnauthorized,
|
||||
},
|
||||
},
|
||||
unauthorizedResponseDescriptor,
|
||||
repositoryNotFoundResponseDescriptor,
|
||||
deniedResponseDescriptor,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -517,7 +489,7 @@ var routeDescriptors = []RouteDescriptor{
|
||||
},
|
||||
{
|
||||
Name: RouteNameManifest,
|
||||
Path: "/v2/{name:" + RepositoryNameRegexp.String() + "}/manifests/{reference:" + TagNameRegexp.String() + "|" + digest.DigestRegexp.String() + "}",
|
||||
Path: "/v2/{name:" + reference.NameRegexp.String() + "}/manifests/{reference:" + reference.TagRegexp.String() + "|" + digest.DigestRegexp.String() + "}",
|
||||
Entity: "Manifest",
|
||||
Description: "Create, update, delete and retrieve manifests.",
|
||||
Methods: []MethodDescriptor{
|
||||
@@ -560,29 +532,9 @@ var routeDescriptors = []RouteDescriptor{
|
||||
Format: errorsBody,
|
||||
},
|
||||
},
|
||||
{
|
||||
StatusCode: http.StatusUnauthorized,
|
||||
Description: "The client does not have access to the repository.",
|
||||
Body: BodyDescriptor{
|
||||
ContentType: "application/json; charset=utf-8",
|
||||
Format: errorsBody,
|
||||
},
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
ErrorCodeUnauthorized,
|
||||
},
|
||||
},
|
||||
{
|
||||
Description: "The named manifest is not known to the registry.",
|
||||
StatusCode: http.StatusNotFound,
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
ErrorCodeNameUnknown,
|
||||
ErrorCodeManifestUnknown,
|
||||
},
|
||||
Body: BodyDescriptor{
|
||||
ContentType: "application/json; charset=utf-8",
|
||||
Format: errorsBody,
|
||||
},
|
||||
},
|
||||
unauthorizedResponseDescriptor,
|
||||
repositoryNotFoundResponseDescriptor,
|
||||
deniedResponseDescriptor,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -637,17 +589,9 @@ var routeDescriptors = []RouteDescriptor{
|
||||
ErrorCodeBlobUnknown,
|
||||
},
|
||||
},
|
||||
{
|
||||
StatusCode: http.StatusUnauthorized,
|
||||
Description: "The client does not have permission to push to the repository.",
|
||||
Body: BodyDescriptor{
|
||||
ContentType: "application/json; charset=utf-8",
|
||||
Format: errorsBody,
|
||||
},
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
ErrorCodeUnauthorized,
|
||||
},
|
||||
},
|
||||
unauthorizedResponseDescriptor,
|
||||
repositoryNotFoundResponseDescriptor,
|
||||
deniedResponseDescriptor,
|
||||
{
|
||||
Name: "Missing Layer(s)",
|
||||
Description: "One or more layers may be missing during a manifest upload. If so, the missing layers will be enumerated in the error response.",
|
||||
@@ -671,22 +615,11 @@ var routeDescriptors = []RouteDescriptor{
|
||||
},
|
||||
},
|
||||
{
|
||||
StatusCode: http.StatusUnauthorized,
|
||||
Headers: []ParameterDescriptor{
|
||||
authChallengeHeader,
|
||||
{
|
||||
Name: "Content-Length",
|
||||
Type: "integer",
|
||||
Description: "Length of the JSON error response body.",
|
||||
Format: "<length>",
|
||||
},
|
||||
},
|
||||
Name: "Not allowed",
|
||||
Description: "Manifest put is not allowed because the registry is configured as a pull-through cache or for some other reason",
|
||||
StatusCode: http.StatusMethodNotAllowed,
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
ErrorCodeUnauthorized,
|
||||
},
|
||||
Body: BodyDescriptor{
|
||||
ContentType: "application/json; charset=utf-8",
|
||||
Format: errorsBody,
|
||||
errcode.ErrorCodeUnsupported,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -725,25 +658,9 @@ var routeDescriptors = []RouteDescriptor{
|
||||
Format: errorsBody,
|
||||
},
|
||||
},
|
||||
{
|
||||
StatusCode: http.StatusUnauthorized,
|
||||
Headers: []ParameterDescriptor{
|
||||
authChallengeHeader,
|
||||
{
|
||||
Name: "Content-Length",
|
||||
Type: "integer",
|
||||
Description: "Length of the JSON error response body.",
|
||||
Format: "<length>",
|
||||
},
|
||||
},
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
ErrorCodeUnauthorized,
|
||||
},
|
||||
Body: BodyDescriptor{
|
||||
ContentType: "application/json; charset=utf-8",
|
||||
Format: errorsBody,
|
||||
},
|
||||
},
|
||||
unauthorizedResponseDescriptor,
|
||||
repositoryNotFoundResponseDescriptor,
|
||||
deniedResponseDescriptor,
|
||||
{
|
||||
Name: "Unknown Manifest",
|
||||
Description: "The specified `name` or `reference` are unknown to the registry and the delete was unable to proceed. Clients can assume the manifest was already deleted if this response is returned.",
|
||||
@@ -757,6 +674,14 @@ var routeDescriptors = []RouteDescriptor{
|
||||
Format: errorsBody,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "Not allowed",
|
||||
Description: "Manifest delete is not allowed because the registry is configured as a pull-through cache or `delete` has been disabled.",
|
||||
StatusCode: http.StatusMethodNotAllowed,
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
errcode.ErrorCodeUnsupported,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -766,7 +691,7 @@ var routeDescriptors = []RouteDescriptor{
|
||||
|
||||
{
|
||||
Name: RouteNameBlob,
|
||||
Path: "/v2/{name:" + RepositoryNameRegexp.String() + "}/blobs/{digest:" + digest.DigestRegexp.String() + "}",
|
||||
Path: "/v2/{name:" + reference.NameRegexp.String() + "}/blobs/{digest:" + digest.DigestRegexp.String() + "}",
|
||||
Entity: "Blob",
|
||||
Description: "Operations on blobs identified by `name` and `digest`. Used to fetch or delete layers by digest.",
|
||||
Methods: []MethodDescriptor{
|
||||
@@ -829,7 +754,6 @@ var routeDescriptors = []RouteDescriptor{
|
||||
Format: errorsBody,
|
||||
},
|
||||
},
|
||||
unauthorizedResponse,
|
||||
{
|
||||
Description: "The blob, identified by `name` and `digest`, is unknown to the registry.",
|
||||
StatusCode: http.StatusNotFound,
|
||||
@@ -842,6 +766,9 @@ var routeDescriptors = []RouteDescriptor{
|
||||
ErrorCodeBlobUnknown,
|
||||
},
|
||||
},
|
||||
unauthorizedResponseDescriptor,
|
||||
repositoryNotFoundResponseDescriptor,
|
||||
deniedResponseDescriptor,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -898,7 +825,6 @@ var routeDescriptors = []RouteDescriptor{
|
||||
Format: errorsBody,
|
||||
},
|
||||
},
|
||||
unauthorizedResponse,
|
||||
{
|
||||
StatusCode: http.StatusNotFound,
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
@@ -914,6 +840,9 @@ var routeDescriptors = []RouteDescriptor{
|
||||
Description: "The range specification cannot be satisfied for the requested content. This can happen when the range is not formatted correctly or if the range is outside of the valid size of the content.",
|
||||
StatusCode: http.StatusRequestedRangeNotSatisfiable,
|
||||
},
|
||||
unauthorizedResponseDescriptor,
|
||||
repositoryNotFoundResponseDescriptor,
|
||||
deniedResponseDescriptor,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -967,16 +896,19 @@ var routeDescriptors = []RouteDescriptor{
|
||||
},
|
||||
},
|
||||
{
|
||||
Description: "Delete is not enabled on the registry",
|
||||
Description: "Blob delete is not allowed because the registry is configured as a pull-through cache or `delete` has been disabled",
|
||||
StatusCode: http.StatusMethodNotAllowed,
|
||||
Body: BodyDescriptor{
|
||||
ContentType: "application/json; charset=utf-8",
|
||||
Format: errorsBody,
|
||||
},
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
ErrorCodeUnsupported,
|
||||
errcode.ErrorCodeUnsupported,
|
||||
},
|
||||
},
|
||||
unauthorizedResponseDescriptor,
|
||||
repositoryNotFoundResponseDescriptor,
|
||||
deniedResponseDescriptor,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -990,7 +922,7 @@ var routeDescriptors = []RouteDescriptor{
|
||||
|
||||
{
|
||||
Name: RouteNameBlobUpload,
|
||||
Path: "/v2/{name:" + RepositoryNameRegexp.String() + "}/blobs/uploads/",
|
||||
Path: "/v2/{name:" + reference.NameRegexp.String() + "}/blobs/uploads/",
|
||||
Entity: "Initiate Blob Upload",
|
||||
Description: "Initiate a blob upload. This endpoint can be used to create resumable uploads or monolithic uploads.",
|
||||
Methods: []MethodDescriptor{
|
||||
@@ -1050,7 +982,17 @@ var routeDescriptors = []RouteDescriptor{
|
||||
ErrorCodeNameInvalid,
|
||||
},
|
||||
},
|
||||
unauthorizedResponsePush,
|
||||
{
|
||||
Name: "Not allowed",
|
||||
Description: "Blob upload is not allowed because the registry is configured as a pull-through cache or for some other reason",
|
||||
StatusCode: http.StatusMethodNotAllowed,
|
||||
ErrorCodes: []errcode.ErrorCode{
|
||||
errcode.ErrorCodeUnsupported,
|
||||
},
|
||||
},
|
||||
unauthorizedResponseDescriptor,
|
||||
repositoryNotFoundResponseDescriptor,
|
||||
deniedResponseDescriptor,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -1094,7 +1036,9 @@ var routeDescriptors = []RouteDescriptor{
|
||||
ErrorCodeNameInvalid,
|
||||
},
|
||||
},
|
||||
unauthorizedResponsePush,
|
||||
unauthorizedResponseDescriptor,
|
||||
repositoryNotFoundResponseDescriptor,
|
||||
deniedResponseDescriptor,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1104,7 +1048,7 @@ var routeDescriptors = []RouteDescriptor{
|
||||
|
||||
{
|
||||
Name: RouteNameBlobUploadChunk,
|
||||
Path: "/v2/{name:" + RepositoryNameRegexp.String() + "}/blobs/uploads/{uuid:[a-zA-Z0-9-_.=]+}",
|
||||
Path: "/v2/{name:" + reference.NameRegexp.String() + "}/blobs/uploads/{uuid:[a-zA-Z0-9-_.=]+}",
|
||||
Entity: "Blob Upload",
|
||||
Description: "Interact with blob uploads. Clients should never assemble URLs for this endpoint and should only take it through the `Location` header on related API requests. The `Location` header and its parameters should be preserved by clients, using the latest value returned via upload related API calls.",
|
||||
Methods: []MethodDescriptor{
|
||||
@@ -1153,7 +1097,6 @@ var routeDescriptors = []RouteDescriptor{
|
||||
Format: errorsBody,
|
||||
},
|
||||
},
|
||||
unauthorizedResponse,
|
||||
{
|
||||
Description: "The upload is unknown to the registry. The upload must be restarted.",
|
||||
StatusCode: http.StatusNotFound,
|
||||
@@ -1165,6 +1108,9 @@ var routeDescriptors = []RouteDescriptor{
|
||||
Format: errorsBody,
|
||||
},
|
||||
},
|
||||
unauthorizedResponseDescriptor,
|
||||
repositoryNotFoundResponseDescriptor,
|
||||
deniedResponseDescriptor,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1225,7 +1171,6 @@ var routeDescriptors = []RouteDescriptor{
|
||||
Format: errorsBody,
|
||||
},
|
||||
},
|
||||
unauthorizedResponsePush,
|
||||
{
|
||||
Description: "The upload is unknown to the registry. The upload must be restarted.",
|
||||
StatusCode: http.StatusNotFound,
|
||||
@@ -1237,6 +1182,9 @@ var routeDescriptors = []RouteDescriptor{
|
||||
Format: errorsBody,
|
||||
},
|
||||
},
|
||||
unauthorizedResponseDescriptor,
|
||||
repositoryNotFoundResponseDescriptor,
|
||||
deniedResponseDescriptor,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -1304,7 +1252,6 @@ var routeDescriptors = []RouteDescriptor{
|
||||
Format: errorsBody,
|
||||
},
|
||||
},
|
||||
unauthorizedResponsePush,
|
||||
{
|
||||
Description: "The upload is unknown to the registry. The upload must be restarted.",
|
||||
StatusCode: http.StatusNotFound,
|
||||
@@ -1320,6 +1267,9 @@ var routeDescriptors = []RouteDescriptor{
|
||||
Description: "The `Content-Range` specification cannot be accepted, either because it does not overlap with the current progress or it is invalid.",
|
||||
StatusCode: http.StatusRequestedRangeNotSatisfiable,
|
||||
},
|
||||
unauthorizedResponseDescriptor,
|
||||
repositoryNotFoundResponseDescriptor,
|
||||
deniedResponseDescriptor,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1389,13 +1339,13 @@ var routeDescriptors = []RouteDescriptor{
|
||||
ErrorCodeDigestInvalid,
|
||||
ErrorCodeNameInvalid,
|
||||
ErrorCodeBlobUploadInvalid,
|
||||
errcode.ErrorCodeUnsupported,
|
||||
},
|
||||
Body: BodyDescriptor{
|
||||
ContentType: "application/json; charset=utf-8",
|
||||
Format: errorsBody,
|
||||
},
|
||||
},
|
||||
unauthorizedResponsePush,
|
||||
{
|
||||
Description: "The upload is unknown to the registry. The upload must be restarted.",
|
||||
StatusCode: http.StatusNotFound,
|
||||
@@ -1407,6 +1357,9 @@ var routeDescriptors = []RouteDescriptor{
|
||||
Format: errorsBody,
|
||||
},
|
||||
},
|
||||
unauthorizedResponseDescriptor,
|
||||
repositoryNotFoundResponseDescriptor,
|
||||
deniedResponseDescriptor,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1449,7 +1402,6 @@ var routeDescriptors = []RouteDescriptor{
|
||||
Format: errorsBody,
|
||||
},
|
||||
},
|
||||
unauthorizedResponse,
|
||||
{
|
||||
Description: "The upload is unknown to the registry. The client may ignore this error and assume the upload has been deleted.",
|
||||
StatusCode: http.StatusNotFound,
|
||||
@@ -1461,6 +1413,9 @@ var routeDescriptors = []RouteDescriptor{
|
||||
Format: errorsBody,
|
||||
},
|
||||
},
|
||||
unauthorizedResponseDescriptor,
|
||||
repositoryNotFoundResponseDescriptor,
|
||||
deniedResponseDescriptor,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
18
vendor/github.com/docker/distribution/registry/api/v2/errors.go
generated
vendored
18
vendor/github.com/docker/distribution/registry/api/v2/errors.go
generated
vendored
@@ -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{
|
||||
|
83
vendor/github.com/docker/distribution/registry/api/v2/names.go
generated
vendored
83
vendor/github.com/docker/distribution/registry/api/v2/names.go
generated
vendored
@@ -1,83 +0,0 @@
|
||||
package v2
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// TODO(stevvooe): Move these definitions to the future "reference" package.
|
||||
// While they are used with v2 definitions, their relevance expands beyond.
|
||||
|
||||
const (
|
||||
// RepositoryNameTotalLengthMax is the maximum total number of characters in
|
||||
// a repository name
|
||||
RepositoryNameTotalLengthMax = 255
|
||||
)
|
||||
|
||||
// RepositoryNameComponentRegexp restricts registry path component names to
|
||||
// start with at least one letter or number, with following parts able to
|
||||
// be separated by one period, dash or underscore.
|
||||
var RepositoryNameComponentRegexp = regexp.MustCompile(`[a-z0-9]+(?:[._-][a-z0-9]+)*`)
|
||||
|
||||
// RepositoryNameComponentAnchoredRegexp is the version of
|
||||
// RepositoryNameComponentRegexp which must completely match the content
|
||||
var RepositoryNameComponentAnchoredRegexp = regexp.MustCompile(`^` + RepositoryNameComponentRegexp.String() + `$`)
|
||||
|
||||
// RepositoryNameRegexp builds on RepositoryNameComponentRegexp to allow
|
||||
// multiple path components, separated by a forward slash.
|
||||
var RepositoryNameRegexp = regexp.MustCompile(`(?:` + RepositoryNameComponentRegexp.String() + `/)*` + RepositoryNameComponentRegexp.String())
|
||||
|
||||
// TagNameRegexp matches valid tag names. From docker/docker:graph/tags.go.
|
||||
var TagNameRegexp = regexp.MustCompile(`[\w][\w.-]{0,127}`)
|
||||
|
||||
// TagNameAnchoredRegexp matches valid tag names, anchored at the start and
|
||||
// end of the matched string.
|
||||
var TagNameAnchoredRegexp = regexp.MustCompile("^" + TagNameRegexp.String() + "$")
|
||||
|
||||
var (
|
||||
// ErrRepositoryNameEmpty is returned for empty, invalid repository names.
|
||||
ErrRepositoryNameEmpty = fmt.Errorf("repository name must have at least one component")
|
||||
|
||||
// ErrRepositoryNameLong is returned when a repository name is longer than
|
||||
// RepositoryNameTotalLengthMax
|
||||
ErrRepositoryNameLong = fmt.Errorf("repository name must not be more than %v characters", RepositoryNameTotalLengthMax)
|
||||
|
||||
// ErrRepositoryNameComponentInvalid is returned when a repository name does
|
||||
// not match RepositoryNameComponentRegexp
|
||||
ErrRepositoryNameComponentInvalid = fmt.Errorf("repository name component must match %q", RepositoryNameComponentRegexp.String())
|
||||
)
|
||||
|
||||
// ValidateRepositoryName ensures the repository name is valid for use in the
|
||||
// registry. This function accepts a superset of what might be accepted by
|
||||
// docker core or docker hub. If the name does not pass validation, an error,
|
||||
// describing the conditions, is returned.
|
||||
//
|
||||
// Effectively, the name should comply with the following grammar:
|
||||
//
|
||||
// alpha-numeric := /[a-z0-9]+/
|
||||
// separator := /[._-]/
|
||||
// component := alpha-numeric [separator alpha-numeric]*
|
||||
// namespace := component ['/' component]*
|
||||
//
|
||||
// The result of the production, known as the "namespace", should be limited
|
||||
// to 255 characters.
|
||||
func ValidateRepositoryName(name string) error {
|
||||
if name == "" {
|
||||
return ErrRepositoryNameEmpty
|
||||
}
|
||||
|
||||
if len(name) > RepositoryNameTotalLengthMax {
|
||||
return ErrRepositoryNameLong
|
||||
}
|
||||
|
||||
components := strings.Split(name, "/")
|
||||
|
||||
for _, component := range components {
|
||||
if !RepositoryNameComponentAnchoredRegexp.MatchString(component) {
|
||||
return ErrRepositoryNameComponentInvalid
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
231
vendor/github.com/docker/distribution/registry/api/v2/names_test.go
generated
vendored
231
vendor/github.com/docker/distribution/registry/api/v2/names_test.go
generated
vendored
@@ -1,231 +0,0 @@
|
||||
package v2
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var (
|
||||
// regexpTestcases is a unified set of testcases for
|
||||
// TestValidateRepositoryName and TestRepositoryNameRegexp.
|
||||
// Some of them are valid inputs for one and not the other.
|
||||
regexpTestcases = []struct {
|
||||
// input is the repository name or name component testcase
|
||||
input string
|
||||
// err is the error expected from ValidateRepositoryName, or nil
|
||||
err error
|
||||
// invalid should be true if the testcase is *not* expected to
|
||||
// match RepositoryNameRegexp
|
||||
invalid bool
|
||||
}{
|
||||
{
|
||||
input: "",
|
||||
err: ErrRepositoryNameEmpty,
|
||||
},
|
||||
{
|
||||
input: "short",
|
||||
},
|
||||
{
|
||||
input: "simple/name",
|
||||
},
|
||||
{
|
||||
input: "library/ubuntu",
|
||||
},
|
||||
{
|
||||
input: "docker/stevvooe/app",
|
||||
},
|
||||
{
|
||||
input: "aa/aa/aa/aa/aa/aa/aa/aa/aa/bb/bb/bb/bb/bb/bb",
|
||||
},
|
||||
{
|
||||
input: "aa/aa/bb/bb/bb",
|
||||
},
|
||||
{
|
||||
input: "a/a/a/b/b",
|
||||
},
|
||||
{
|
||||
input: "a/a/a/a/",
|
||||
err: ErrRepositoryNameComponentInvalid,
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
input: "a//a/a",
|
||||
err: ErrRepositoryNameComponentInvalid,
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
input: "a",
|
||||
},
|
||||
{
|
||||
input: "a/aa",
|
||||
},
|
||||
{
|
||||
input: "aa/a",
|
||||
},
|
||||
{
|
||||
input: "a/aa/a",
|
||||
},
|
||||
{
|
||||
input: "foo.com/",
|
||||
err: ErrRepositoryNameComponentInvalid,
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
// TODO: this testcase should be valid once we switch to
|
||||
// the reference package.
|
||||
input: "foo.com:8080/bar",
|
||||
err: ErrRepositoryNameComponentInvalid,
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
input: "foo.com/bar",
|
||||
},
|
||||
{
|
||||
input: "foo.com/bar/baz",
|
||||
},
|
||||
{
|
||||
input: "foo.com/bar/baz/quux",
|
||||
},
|
||||
{
|
||||
input: "blog.foo.com/bar/baz",
|
||||
},
|
||||
{
|
||||
input: "asdf",
|
||||
},
|
||||
{
|
||||
input: "asdf$$^/aa",
|
||||
err: ErrRepositoryNameComponentInvalid,
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
input: "aa-a/aa",
|
||||
},
|
||||
{
|
||||
input: "aa/aa",
|
||||
},
|
||||
{
|
||||
input: "a-a/a-a",
|
||||
},
|
||||
{
|
||||
input: "a-/a/a/a",
|
||||
err: ErrRepositoryNameComponentInvalid,
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
input: strings.Repeat("a", 255),
|
||||
},
|
||||
{
|
||||
input: strings.Repeat("a", 256),
|
||||
err: ErrRepositoryNameLong,
|
||||
},
|
||||
{
|
||||
input: "-foo/bar",
|
||||
err: ErrRepositoryNameComponentInvalid,
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
input: "foo/bar-",
|
||||
err: ErrRepositoryNameComponentInvalid,
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
input: "foo-/bar",
|
||||
err: ErrRepositoryNameComponentInvalid,
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
input: "foo/-bar",
|
||||
err: ErrRepositoryNameComponentInvalid,
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
input: "_foo/bar",
|
||||
err: ErrRepositoryNameComponentInvalid,
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
input: "foo/bar_",
|
||||
err: ErrRepositoryNameComponentInvalid,
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
input: "____/____",
|
||||
err: ErrRepositoryNameComponentInvalid,
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
input: "_docker/_docker",
|
||||
err: ErrRepositoryNameComponentInvalid,
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
input: "docker_/docker_",
|
||||
err: ErrRepositoryNameComponentInvalid,
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
input: "b.gcr.io/test.example.com/my-app", // embedded domain component
|
||||
},
|
||||
// TODO(stevvooe): The following is a punycode domain name that we may
|
||||
// want to allow in the future. Currently, this is not allowed but we
|
||||
// may want to change this in the future. Adding this here as invalid
|
||||
// for the time being.
|
||||
{
|
||||
input: "xn--n3h.com/myimage", // http://☃.com in punycode
|
||||
err: ErrRepositoryNameComponentInvalid,
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
input: "xn--7o8h.com/myimage", // http://🐳.com in punycode
|
||||
err: ErrRepositoryNameComponentInvalid,
|
||||
invalid: true,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// TestValidateRepositoryName tests the ValidateRepositoryName function,
|
||||
// which uses RepositoryNameComponentAnchoredRegexp for validation
|
||||
func TestValidateRepositoryName(t *testing.T) {
|
||||
for _, testcase := range regexpTestcases {
|
||||
failf := func(format string, v ...interface{}) {
|
||||
t.Logf(strconv.Quote(testcase.input)+": "+format, v...)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if err := ValidateRepositoryName(testcase.input); err != testcase.err {
|
||||
if testcase.err != nil {
|
||||
if err != nil {
|
||||
failf("unexpected error for invalid repository: got %v, expected %v", err, testcase.err)
|
||||
} else {
|
||||
failf("expected invalid repository: %v", testcase.err)
|
||||
}
|
||||
} else {
|
||||
if err != nil {
|
||||
// Wrong error returned.
|
||||
failf("unexpected error validating repository name: %v, expected %v", err, testcase.err)
|
||||
} else {
|
||||
failf("unexpected error validating repository name: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRepositoryNameRegexp(t *testing.T) {
|
||||
for _, testcase := range regexpTestcases {
|
||||
failf := func(format string, v ...interface{}) {
|
||||
t.Logf(strconv.Quote(testcase.input)+": "+format, v...)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
matches := RepositoryNameRegexp.FindString(testcase.input) == testcase.input
|
||||
if matches == testcase.invalid {
|
||||
if testcase.invalid {
|
||||
failf("expected invalid repository name %s", testcase.input)
|
||||
} else {
|
||||
failf("expected valid repository name %s", testcase.input)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
8
vendor/github.com/docker/distribution/registry/api/v2/routes_test.go
generated
vendored
8
vendor/github.com/docker/distribution/registry/api/v2/routes_test.go
generated
vendored
@@ -170,6 +170,14 @@ func TestRouter(t *testing.T) {
|
||||
"name": "foo/bar/manifests",
|
||||
},
|
||||
},
|
||||
{
|
||||
RouteName: RouteNameManifest,
|
||||
RequestURI: "/v2/locahost:8080/foo/bar/baz/manifests/tag",
|
||||
Vars: map[string]string{
|
||||
"name": "locahost:8080/foo/bar/baz",
|
||||
"reference": "tag",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
checkTestRouter(t, testCases, "", true)
|
||||
|
40
vendor/github.com/docker/distribution/registry/api/v2/urls_test.go
generated
vendored
40
vendor/github.com/docker/distribution/registry/api/v2/urls_test.go
generated
vendored
@@ -158,8 +158,9 @@ func TestBuilderFromRequest(t *testing.T) {
|
||||
forwardedHostHeader2.Set("X-Forwarded-Host", "first.example.com, proxy1.example.com")
|
||||
|
||||
testRequests := []struct {
|
||||
request *http.Request
|
||||
base string
|
||||
request *http.Request
|
||||
base string
|
||||
configHost url.URL
|
||||
}{
|
||||
{
|
||||
request: &http.Request{URL: u, Host: u.Host},
|
||||
@@ -177,10 +178,23 @@ func TestBuilderFromRequest(t *testing.T) {
|
||||
request: &http.Request{URL: u, Host: u.Host, Header: forwardedHostHeader2},
|
||||
base: "http://first.example.com",
|
||||
},
|
||||
{
|
||||
request: &http.Request{URL: u, Host: u.Host, Header: forwardedHostHeader2},
|
||||
base: "https://third.example.com:5000",
|
||||
configHost: url.URL{
|
||||
Scheme: "https",
|
||||
Host: "third.example.com:5000",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tr := range testRequests {
|
||||
builder := NewURLBuilderFromRequest(tr.request)
|
||||
var builder *URLBuilder
|
||||
if tr.configHost.Scheme != "" && tr.configHost.Host != "" {
|
||||
builder = NewURLBuilder(&tr.configHost)
|
||||
} else {
|
||||
builder = NewURLBuilderFromRequest(tr.request)
|
||||
}
|
||||
|
||||
for _, testCase := range makeURLBuilderTestCases(builder) {
|
||||
url, err := testCase.build()
|
||||
@@ -207,8 +221,9 @@ func TestBuilderFromRequestWithPrefix(t *testing.T) {
|
||||
forwardedProtoHeader.Set("X-Forwarded-Proto", "https")
|
||||
|
||||
testRequests := []struct {
|
||||
request *http.Request
|
||||
base string
|
||||
request *http.Request
|
||||
base string
|
||||
configHost url.URL
|
||||
}{
|
||||
{
|
||||
request: &http.Request{URL: u, Host: u.Host},
|
||||
@@ -218,10 +233,23 @@ func TestBuilderFromRequestWithPrefix(t *testing.T) {
|
||||
request: &http.Request{URL: u, Host: u.Host, Header: forwardedProtoHeader},
|
||||
base: "https://example.com/prefix/",
|
||||
},
|
||||
{
|
||||
request: &http.Request{URL: u, Host: u.Host, Header: forwardedProtoHeader},
|
||||
base: "https://subdomain.example.com/prefix/",
|
||||
configHost: url.URL{
|
||||
Scheme: "https",
|
||||
Host: "subdomain.example.com/prefix",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tr := range testRequests {
|
||||
builder := NewURLBuilderFromRequest(tr.request)
|
||||
var builder *URLBuilder
|
||||
if tr.configHost.Scheme != "" && tr.configHost.Host != "" {
|
||||
builder = NewURLBuilder(&tr.configHost)
|
||||
} else {
|
||||
builder = NewURLBuilderFromRequest(tr.request)
|
||||
}
|
||||
|
||||
for _, testCase := range makeURLBuilderTestCases(builder) {
|
||||
url, err := testCase.build()
|
||||
|
Reference in New Issue
Block a user