2014-12-12 06:10:18 +00:00
|
|
|
package v2
|
2014-12-10 05:25:54 +00:00
|
|
|
|
|
|
|
import (
|
2015-05-15 01:21:39 +00:00
|
|
|
"net/http"
|
2014-12-10 05:25:54 +00:00
|
|
|
|
2020-08-24 11:18:39 +00:00
|
|
|
"github.com/distribution/distribution/v3/registry/api/errcode"
|
2015-05-15 01:21:39 +00:00
|
|
|
)
|
2014-12-10 05:25:54 +00:00
|
|
|
|
2015-06-03 13:52:39 +00:00
|
|
|
const errGroup = "registry.api.v2"
|
|
|
|
|
2015-05-27 01:16:45 +00:00
|
|
|
var (
|
|
|
|
// ErrorCodeDigestInvalid is returned when uploading a blob if the
|
|
|
|
// provided digest does not match the blob contents.
|
2015-06-03 13:52:39 +00:00
|
|
|
ErrorCodeDigestInvalid = errcode.Register(errGroup, errcode.ErrorDescriptor{
|
2015-05-15 01:21:39 +00:00
|
|
|
Value: "DIGEST_INVALID",
|
|
|
|
Message: "provided digest did not match uploaded content",
|
|
|
|
Description: `When a blob is uploaded, the registry will check that
|
|
|
|
the content matches the digest provided by the client. The error may
|
|
|
|
include a detail structure with the key "digest", including the
|
|
|
|
invalid digest string. This error may also be returned when a manifest
|
|
|
|
includes an invalid layer digest.`,
|
|
|
|
HTTPStatusCode: http.StatusBadRequest,
|
2015-05-27 01:16:45 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
// ErrorCodeSizeInvalid is returned when uploading a blob if the provided
|
2015-06-03 13:52:39 +00:00
|
|
|
ErrorCodeSizeInvalid = errcode.Register(errGroup, errcode.ErrorDescriptor{
|
2015-05-15 01:21:39 +00:00
|
|
|
Value: "SIZE_INVALID",
|
|
|
|
Message: "provided length did not match content length",
|
|
|
|
Description: `When a layer is uploaded, the provided size will be
|
|
|
|
checked against the uploaded content. If they do not match, this error
|
|
|
|
will be returned.`,
|
|
|
|
HTTPStatusCode: http.StatusBadRequest,
|
2015-05-27 01:16:45 +00:00
|
|
|
})
|
|
|
|
|
2020-08-19 09:07:38 +00:00
|
|
|
// ErrorCodeRangeInvalid is returned when uploading a blob if the provided
|
|
|
|
// content range is invalid.
|
|
|
|
ErrorCodeRangeInvalid = errcode.Register(errGroup, errcode.ErrorDescriptor{
|
|
|
|
Value: "RANGE_INVALID",
|
|
|
|
Message: "invalid content range",
|
|
|
|
Description: `When a layer is uploaded, the provided range is checked
|
|
|
|
against the uploaded chunk. This error is returned if the range is
|
|
|
|
out of order.`,
|
|
|
|
HTTPStatusCode: http.StatusRequestedRangeNotSatisfiable,
|
|
|
|
})
|
|
|
|
|
2015-05-27 01:16:45 +00:00
|
|
|
// ErrorCodeNameInvalid is returned when the name in the manifest does not
|
|
|
|
// match the provided name.
|
2015-06-03 13:52:39 +00:00
|
|
|
ErrorCodeNameInvalid = errcode.Register(errGroup, errcode.ErrorDescriptor{
|
2015-05-15 01:21:39 +00:00
|
|
|
Value: "NAME_INVALID",
|
|
|
|
Message: "invalid repository name",
|
|
|
|
Description: `Invalid repository name encountered either during
|
|
|
|
manifest validation or any API operation.`,
|
|
|
|
HTTPStatusCode: http.StatusBadRequest,
|
2015-05-27 01:16:45 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
// ErrorCodeTagInvalid is returned when the tag in the manifest does not
|
|
|
|
// match the provided tag.
|
2015-06-03 13:52:39 +00:00
|
|
|
ErrorCodeTagInvalid = errcode.Register(errGroup, errcode.ErrorDescriptor{
|
2015-05-15 01:21:39 +00:00
|
|
|
Value: "TAG_INVALID",
|
|
|
|
Message: "manifest tag did not match URI",
|
|
|
|
Description: `During a manifest upload, if the tag in the manifest
|
|
|
|
does not match the uri tag, this error will be returned.`,
|
|
|
|
HTTPStatusCode: http.StatusBadRequest,
|
2015-05-27 01:16:45 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
// ErrorCodeNameUnknown when the repository name is not known.
|
2015-06-03 13:52:39 +00:00
|
|
|
ErrorCodeNameUnknown = errcode.Register(errGroup, errcode.ErrorDescriptor{
|
2015-05-15 01:21:39 +00:00
|
|
|
Value: "NAME_UNKNOWN",
|
|
|
|
Message: "repository name not known to registry",
|
|
|
|
Description: `This is returned if the name used during an operation is
|
|
|
|
unknown to the registry.`,
|
|
|
|
HTTPStatusCode: http.StatusNotFound,
|
2015-05-27 01:16:45 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
// ErrorCodeManifestUnknown returned when image manifest is unknown.
|
2015-06-03 13:52:39 +00:00
|
|
|
ErrorCodeManifestUnknown = errcode.Register(errGroup, errcode.ErrorDescriptor{
|
2015-05-15 01:21:39 +00:00
|
|
|
Value: "MANIFEST_UNKNOWN",
|
|
|
|
Message: "manifest unknown",
|
|
|
|
Description: `This error is returned when the manifest, identified by
|
|
|
|
name and tag is unknown to the repository.`,
|
|
|
|
HTTPStatusCode: http.StatusNotFound,
|
2015-05-27 01:16:45 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
// ErrorCodeManifestInvalid returned when an image manifest is invalid,
|
|
|
|
// typically during a PUT operation. This error encompasses all errors
|
|
|
|
// encountered during manifest validation that aren't signature errors.
|
2015-06-03 13:52:39 +00:00
|
|
|
ErrorCodeManifestInvalid = errcode.Register(errGroup, errcode.ErrorDescriptor{
|
2015-05-15 01:21:39 +00:00
|
|
|
Value: "MANIFEST_INVALID",
|
|
|
|
Message: "manifest invalid",
|
|
|
|
Description: `During upload, manifests undergo several checks ensuring
|
|
|
|
validity. If those checks fail, this error may be returned, unless a
|
|
|
|
more specific error is included. The detail will contain information
|
|
|
|
the failed validation.`,
|
|
|
|
HTTPStatusCode: http.StatusBadRequest,
|
2015-05-27 01:16:45 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
// ErrorCodeManifestUnverified is returned when the manifest fails
|
2016-02-11 00:26:29 +00:00
|
|
|
// signature verification.
|
2015-06-03 13:52:39 +00:00
|
|
|
ErrorCodeManifestUnverified = errcode.Register(errGroup, errcode.ErrorDescriptor{
|
2015-05-15 01:21:39 +00:00
|
|
|
Value: "MANIFEST_UNVERIFIED",
|
|
|
|
Message: "manifest failed signature verification",
|
|
|
|
Description: `During manifest upload, if the manifest fails signature
|
|
|
|
verification, this error will be returned.`,
|
|
|
|
HTTPStatusCode: http.StatusBadRequest,
|
2015-05-27 01:16:45 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
// ErrorCodeManifestBlobUnknown is returned when a manifest blob is
|
|
|
|
// unknown to the registry.
|
2015-06-03 13:52:39 +00:00
|
|
|
ErrorCodeManifestBlobUnknown = errcode.Register(errGroup, errcode.ErrorDescriptor{
|
2015-05-15 01:21:39 +00:00
|
|
|
Value: "MANIFEST_BLOB_UNKNOWN",
|
|
|
|
Message: "blob unknown to registry",
|
|
|
|
Description: `This error may be returned when a manifest blob is
|
|
|
|
unknown to the registry.`,
|
|
|
|
HTTPStatusCode: http.StatusBadRequest,
|
2015-05-27 01:16:45 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
// ErrorCodeBlobUnknown is returned when a blob is unknown to the
|
|
|
|
// registry. This can happen when the manifest references a nonexistent
|
|
|
|
// layer or the result is not found by a blob fetch.
|
2015-06-03 13:52:39 +00:00
|
|
|
ErrorCodeBlobUnknown = errcode.Register(errGroup, errcode.ErrorDescriptor{
|
2015-05-15 01:21:39 +00:00
|
|
|
Value: "BLOB_UNKNOWN",
|
|
|
|
Message: "blob unknown to registry",
|
|
|
|
Description: `This error may be returned when a blob is unknown to the
|
|
|
|
registry in a specified repository. This can be returned with a
|
|
|
|
standard get or if a manifest references an unknown layer during
|
|
|
|
upload.`,
|
|
|
|
HTTPStatusCode: http.StatusNotFound,
|
2015-05-27 01:16:45 +00:00
|
|
|
})
|
2015-05-15 01:21:39 +00:00
|
|
|
|
2015-05-27 01:16:45 +00:00
|
|
|
// ErrorCodeBlobUploadUnknown is returned when an upload is unknown.
|
2015-06-03 13:52:39 +00:00
|
|
|
ErrorCodeBlobUploadUnknown = errcode.Register(errGroup, errcode.ErrorDescriptor{
|
2015-05-15 01:21:39 +00:00
|
|
|
Value: "BLOB_UPLOAD_UNKNOWN",
|
|
|
|
Message: "blob upload unknown to registry",
|
|
|
|
Description: `If a blob upload has been cancelled or was never
|
|
|
|
started, this error code may be returned.`,
|
|
|
|
HTTPStatusCode: http.StatusNotFound,
|
2015-05-27 01:16:45 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
// ErrorCodeBlobUploadInvalid is returned when an upload is invalid.
|
2015-06-03 13:52:39 +00:00
|
|
|
ErrorCodeBlobUploadInvalid = errcode.Register(errGroup, errcode.ErrorDescriptor{
|
2015-05-15 01:21:39 +00:00
|
|
|
Value: "BLOB_UPLOAD_INVALID",
|
|
|
|
Message: "blob upload invalid",
|
|
|
|
Description: `The blob upload encountered an error and can no
|
|
|
|
longer proceed.`,
|
|
|
|
HTTPStatusCode: http.StatusNotFound,
|
2015-05-27 01:16:45 +00:00
|
|
|
})
|
2020-05-05 09:28:31 +00:00
|
|
|
|
|
|
|
// ErrorCodePaginationNumberInvalid is returned when the `n` parameter is
|
|
|
|
// not an integer, or `n` is negative.
|
|
|
|
ErrorCodePaginationNumberInvalid = errcode.Register(errGroup, errcode.ErrorDescriptor{
|
|
|
|
Value: "PAGINATION_NUMBER_INVALID",
|
|
|
|
Message: "invalid number of results requested",
|
|
|
|
Description: `Returned when the "n" parameter (number of results
|
2023-03-31 11:16:29 +00:00
|
|
|
to return) is not an integer, "n" is negative or "n" is bigger than
|
|
|
|
the maximum allowed.`,
|
2020-05-05 09:28:31 +00:00
|
|
|
HTTPStatusCode: http.StatusBadRequest,
|
|
|
|
})
|
2015-05-27 01:16:45 +00:00
|
|
|
)
|