Initial implementation of Manifest HTTP API
Push, pull and delete of manifest files in the registry have been implemented on top of the storage services. Basic workflows, including reporting of missing manifests are tested, including various proposed response codes. Common testing functionality has been collected into shared methods. A test suite may be emerging but it might better to capture more edge cases (such as resumable upload, range requests, etc.) before we commit to a full approach. To support clearer test cases and simpler handler methods, an application aware urlBuilder has been added. We may want to export the functionality for use in the client, which could allow us to abstract away from gorilla/mux. A few error codes have been added to fill in error conditions missing from the proposal. Some use cases have identified some problems with the approach to error reporting that requires more work to reconcile. To resolve this, the mapping of Go errors into error types needs to pulled out of the handlers and into the application. We also need to move to type-based errors, with rich information, rather than value-based errors. ErrorHandlers will probably replace the http.Handlers to make this work correctly. Unrelated to the above, the "length" parameter has been migrated to "size" for completing layer uploads. This change should have gone out before but these diffs ending up being coupled with the parameter name change due to updates to the layer unit tests.
This commit is contained in:
parent
6fead90736
commit
e809796f59
10 changed files with 581 additions and 210 deletions
29
errors.go
29
errors.go
|
@ -34,6 +34,14 @@ const (
|
|||
// match the provided tag.
|
||||
ErrorCodeInvalidTag
|
||||
|
||||
// ErrorCodeUnknownManifest returned when image manifest name and tag is
|
||||
// unknown, accompanied by a 404 status.
|
||||
ErrorCodeUnknownManifest
|
||||
|
||||
// ErrorCodeInvalidManifest returned when an image manifest is invalid,
|
||||
// typically during a PUT operation.
|
||||
ErrorCodeInvalidManifest
|
||||
|
||||
// ErrorCodeUnverifiedManifest is returned when the manifest fails signature
|
||||
// validation.
|
||||
ErrorCodeUnverifiedManifest
|
||||
|
@ -56,6 +64,8 @@ var errorCodeStrings = map[ErrorCode]string{
|
|||
ErrorCodeInvalidLength: "INVALID_LENGTH",
|
||||
ErrorCodeInvalidName: "INVALID_NAME",
|
||||
ErrorCodeInvalidTag: "INVALID_TAG",
|
||||
ErrorCodeUnknownManifest: "UNKNOWN_MANIFEST",
|
||||
ErrorCodeInvalidManifest: "INVALID_MANIFEST",
|
||||
ErrorCodeUnverifiedManifest: "UNVERIFIED_MANIFEST",
|
||||
ErrorCodeUnknownLayer: "UNKNOWN_LAYER",
|
||||
ErrorCodeUnknownLayerUpload: "UNKNOWN_LAYER_UPLOAD",
|
||||
|
@ -66,12 +76,14 @@ var errorCodesMessages = map[ErrorCode]string{
|
|||
ErrorCodeUnknown: "unknown error",
|
||||
ErrorCodeInvalidDigest: "provided digest did not match uploaded content",
|
||||
ErrorCodeInvalidLength: "provided length did not match content length",
|
||||
ErrorCodeInvalidName: "Manifest name did not match URI",
|
||||
ErrorCodeInvalidTag: "Manifest tag did not match URI",
|
||||
ErrorCodeUnverifiedManifest: "Manifest failed signature validation",
|
||||
ErrorCodeUnknownLayer: "Referenced layer not available",
|
||||
ErrorCodeInvalidName: "manifest name did not match URI",
|
||||
ErrorCodeInvalidTag: "manifest tag did not match URI",
|
||||
ErrorCodeUnknownManifest: "manifest not known",
|
||||
ErrorCodeInvalidManifest: "manifest is invalid",
|
||||
ErrorCodeUnverifiedManifest: "manifest failed signature validation",
|
||||
ErrorCodeUnknownLayer: "referenced layer not available",
|
||||
ErrorCodeUnknownLayerUpload: "cannot resume unknown layer upload",
|
||||
ErrorCodeUntrustedSignature: "Manifest signed by untrusted source",
|
||||
ErrorCodeUntrustedSignature: "manifest signed by untrusted source",
|
||||
}
|
||||
|
||||
var stringToErrorCode map[string]ErrorCode
|
||||
|
@ -178,7 +190,12 @@ func (errs *Errors) Push(code ErrorCode, details ...interface{}) {
|
|||
|
||||
// PushErr pushes an error interface onto the error stack.
|
||||
func (errs *Errors) PushErr(err error) {
|
||||
errs.Errors = append(errs.Errors, err)
|
||||
switch err.(type) {
|
||||
case Error:
|
||||
errs.Errors = append(errs.Errors, err)
|
||||
default:
|
||||
errs.Errors = append(errs.Errors, Error{Message: err.Error()})
|
||||
}
|
||||
}
|
||||
|
||||
func (errs *Errors) Error() string {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue