Round 4
Signed-off-by: Doug Davis <dug@us.ibm.com>
This commit is contained in:
parent
b8b16b78f4
commit
56349665b7
13 changed files with 334 additions and 197 deletions
|
@ -64,7 +64,7 @@ func (imh *imageManifestHandler) GetImageManifest(w http.ResponseWriter, r *http
|
|||
}
|
||||
|
||||
if err != nil {
|
||||
imh.Errors = append(imh.Errors, errcode.NewError(v2.ErrorCodeManifestUnknown, err))
|
||||
imh.Errors = append(imh.Errors, v2.ErrorCodeManifestUnknown.WithDetail(err))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ func (imh *imageManifestHandler) GetImageManifest(w http.ResponseWriter, r *http
|
|||
if imh.Digest == "" {
|
||||
dgst, err := digestManifest(imh, sm)
|
||||
if err != nil {
|
||||
imh.Errors = append(imh.Errors, errcode.NewError(v2.ErrorCodeDigestInvalid, err))
|
||||
imh.Errors = append(imh.Errors, v2.ErrorCodeDigestInvalid.WithDetail(err))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -93,13 +93,13 @@ func (imh *imageManifestHandler) PutImageManifest(w http.ResponseWriter, r *http
|
|||
|
||||
var manifest manifest.SignedManifest
|
||||
if err := dec.Decode(&manifest); err != nil {
|
||||
imh.Errors = append(imh.Errors, errcode.NewError(v2.ErrorCodeManifestInvalid, err))
|
||||
imh.Errors = append(imh.Errors, v2.ErrorCodeManifestInvalid.WithDetail(err))
|
||||
return
|
||||
}
|
||||
|
||||
dgst, err := digestManifest(imh, &manifest)
|
||||
if err != nil {
|
||||
imh.Errors = append(imh.Errors, errcode.NewError(v2.ErrorCodeDigestInvalid, err))
|
||||
imh.Errors = append(imh.Errors, v2.ErrorCodeDigestInvalid.WithDetail(err))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ func (imh *imageManifestHandler) PutImageManifest(w http.ResponseWriter, r *http
|
|||
if imh.Tag != "" {
|
||||
if manifest.Tag != imh.Tag {
|
||||
ctxu.GetLogger(imh).Errorf("invalid tag on manifest payload: %q != %q", manifest.Tag, imh.Tag)
|
||||
imh.Errors = append(imh.Errors, errcode.NewError(v2.ErrorCodeTagInvalid))
|
||||
imh.Errors = append(imh.Errors, v2.ErrorCodeTagInvalid)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -115,11 +115,11 @@ func (imh *imageManifestHandler) PutImageManifest(w http.ResponseWriter, r *http
|
|||
} else if imh.Digest != "" {
|
||||
if dgst != imh.Digest {
|
||||
ctxu.GetLogger(imh).Errorf("payload digest does match: %q != %q", dgst, imh.Digest)
|
||||
imh.Errors = append(imh.Errors, errcode.NewError(v2.ErrorCodeDigestInvalid))
|
||||
imh.Errors = append(imh.Errors, v2.ErrorCodeDigestInvalid)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
imh.Errors = append(imh.Errors, errcode.NewError(v2.ErrorCodeTagInvalid, "no tag or digest specified"))
|
||||
imh.Errors = append(imh.Errors, v2.ErrorCodeTagInvalid.WithDetail("no tag or digest specified"))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -131,19 +131,19 @@ func (imh *imageManifestHandler) PutImageManifest(w http.ResponseWriter, r *http
|
|||
for _, verificationError := range err {
|
||||
switch verificationError := verificationError.(type) {
|
||||
case distribution.ErrManifestBlobUnknown:
|
||||
imh.Errors = append(imh.Errors, errcode.NewError(v2.ErrorCodeBlobUnknown, verificationError.Digest))
|
||||
imh.Errors = append(imh.Errors, v2.ErrorCodeBlobUnknown.WithDetail(verificationError.Digest))
|
||||
case distribution.ErrManifestUnverified:
|
||||
imh.Errors = append(imh.Errors, errcode.NewError(v2.ErrorCodeManifestUnverified))
|
||||
imh.Errors = append(imh.Errors, v2.ErrorCodeManifestUnverified)
|
||||
default:
|
||||
if verificationError == digest.ErrDigestInvalidFormat {
|
||||
imh.Errors = append(imh.Errors, errcode.NewError(v2.ErrorCodeDigestInvalid))
|
||||
imh.Errors = append(imh.Errors, v2.ErrorCodeDigestInvalid)
|
||||
} else {
|
||||
imh.Errors = append(imh.Errors, errcode.NewError(errcode.ErrorCodeUnknown, verificationError))
|
||||
imh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown, verificationError)
|
||||
}
|
||||
}
|
||||
}
|
||||
default:
|
||||
imh.Errors = append(imh.Errors, errcode.NewError(errcode.ErrorCodeUnknown, err))
|
||||
imh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown.WithDetail(err))
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -172,7 +172,7 @@ func (imh *imageManifestHandler) DeleteImageManifest(w http.ResponseWriter, r *h
|
|||
// tag index entries a serious problem in eventually consistent storage.
|
||||
// Once we work out schema version 2, the full deletion system will be
|
||||
// worked out and we can add support back.
|
||||
imh.Errors = append(imh.Errors, errcode.NewError(v2.ErrorCodeUnsupported))
|
||||
imh.Errors = append(imh.Errors, v2.ErrorCodeUnsupported)
|
||||
}
|
||||
|
||||
// digestManifest takes a digest of the given manifest. This belongs somewhere
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue