mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-10 20:50:29 +01:00
Merge pull request #11971 from wy65701436/fixes-11949
fix conformance issue on deleting manifest
This commit is contained in:
commit
b803975b36
@ -25,6 +25,8 @@ const (
|
|||||||
DIGESTINVALID = "DIGEST_INVALID"
|
DIGESTINVALID = "DIGEST_INVALID"
|
||||||
// MANIFESTINVALID ...
|
// MANIFESTINVALID ...
|
||||||
MANIFESTINVALID = "MANIFEST_INVALID"
|
MANIFESTINVALID = "MANIFEST_INVALID"
|
||||||
|
// UNSUPPORTED is for digest UNSUPPORTED error
|
||||||
|
UNSUPPORTED = "UNSUPPORTED"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NotFoundError is error for the case of object not found
|
// NotFoundError is error for the case of object not found
|
||||||
|
@ -31,6 +31,7 @@ var (
|
|||||||
errors.BadRequestCode: http.StatusBadRequest,
|
errors.BadRequestCode: http.StatusBadRequest,
|
||||||
errors.DIGESTINVALID: http.StatusBadRequest,
|
errors.DIGESTINVALID: http.StatusBadRequest,
|
||||||
errors.MANIFESTINVALID: http.StatusBadRequest,
|
errors.MANIFESTINVALID: http.StatusBadRequest,
|
||||||
|
errors.UNSUPPORTED: http.StatusBadRequest,
|
||||||
errors.UnAuthorizedCode: http.StatusUnauthorized,
|
errors.UnAuthorizedCode: http.StatusUnauthorized,
|
||||||
errors.ForbiddenCode: http.StatusForbidden,
|
errors.ForbiddenCode: http.StatusForbidden,
|
||||||
errors.DENIED: http.StatusForbidden,
|
errors.DENIED: http.StatusForbidden,
|
||||||
|
@ -74,12 +74,8 @@ func deleteManifest(w http.ResponseWriter, req *http.Request) {
|
|||||||
// Do not add the logic into GetByReference as it's a shared method for PUT/GET/DELETE/Internal call,
|
// Do not add the logic into GetByReference as it's a shared method for PUT/GET/DELETE/Internal call,
|
||||||
// and NOT_FOUND satisfy PUT/GET/Internal call.
|
// and NOT_FOUND satisfy PUT/GET/Internal call.
|
||||||
if _, err := digest.Parse(reference); err != nil {
|
if _, err := digest.Parse(reference); err != nil {
|
||||||
switch err {
|
serror.SendError(w, errors.Wrapf(err, "unsupported digest %s", reference).WithCode(errors.UNSUPPORTED))
|
||||||
case digest.ErrDigestInvalidFormat:
|
return
|
||||||
serror.SendError(w, errors.New(nil).WithCode(errors.DIGESTINVALID).
|
|
||||||
WithMessage(digest.ErrDigestInvalidFormat.Error()))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
art, err := artifact.Ctl.GetByReference(req.Context(), repository, reference, nil)
|
art, err := artifact.Ctl.GetByReference(req.Context(), repository, reference, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -121,7 +121,7 @@ func (m *manifestTestSuite) TestDeleteManifest() {
|
|||||||
})
|
})
|
||||||
req = httptest.NewRequest(http.MethodDelete, "/v2/library/hello-world/manifests/sha256:418fb88ec412e340cdbef913b8ca1bbe8f9e8dc705f9617414c1f2c8db980180", nil)
|
req = httptest.NewRequest(http.MethodDelete, "/v2/library/hello-world/manifests/sha256:418fb88ec412e340cdbef913b8ca1bbe8f9e8dc705f9617414c1f2c8db980180", nil)
|
||||||
input := &beegocontext.BeegoInput{}
|
input := &beegocontext.BeegoInput{}
|
||||||
input.SetParam(":reference", "sha527:418fb88ec412e340cdbef913b8ca1bbe8f9e8dc705f9617414c1f2c8db980180")
|
input.SetParam(":reference", "sha256:418fb88ec412e340cdbef913b8ca1bbe8f9e8dc705f9617414c1f2c8db980180")
|
||||||
*req = *(req.WithContext(context.WithValue(req.Context(), router.ContextKeyInput{}, input)))
|
*req = *(req.WithContext(context.WithValue(req.Context(), router.ContextKeyInput{}, input)))
|
||||||
w = &httptest.ResponseRecorder{}
|
w = &httptest.ResponseRecorder{}
|
||||||
mock.OnAnything(m.artCtl, "GetByReference").Return(&artifact.Artifact{}, nil)
|
mock.OnAnything(m.artCtl, "GetByReference").Return(&artifact.Artifact{}, nil)
|
||||||
|
Loading…
Reference in New Issue
Block a user