0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-16 21:56:37 -05:00

Merge pull request #80 from rchincha/compl

conformance: fix error msg for DELETE MANIFEST
This commit is contained in:
Ramkumar Chinchani 2020-03-25 14:06:54 -07:00 committed by GitHub
commit 9ecb5cedf3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 3 deletions

View file

@ -9,3 +9,8 @@ linters:
output:
format: colored-line-number
linters-settings:
dupl:
# tokens count to trigger issue, 150 by default
threshold: 200

View file

@ -441,8 +441,11 @@ func (rh *RouteHandler) DeleteManifest(w http.ResponseWriter, r *http.Request) {
WriteJSON(w, http.StatusBadRequest,
NewErrorList(NewError(NAME_UNKNOWN, map[string]string{"name": name})))
case errors.ErrManifestNotFound:
WriteJSON(w, http.StatusBadRequest,
WriteJSON(w, http.StatusNotFound,
NewErrorList(NewError(MANIFEST_UNKNOWN, map[string]string{"reference": reference})))
case errors.ErrBadManifest:
WriteJSON(w, http.StatusBadRequest,
NewErrorList(NewError(UNSUPPORTED, map[string]string{"reference": reference})))
default:
rh.c.Log.Error().Err(err).Msg("unexpected error")
w.WriteHeader(http.StatusInternalServerError)

View file

@ -569,7 +569,7 @@ func CheckWorkflows(t *testing.T, config *compliance.Config) {
// delete again should fail
resp, err = resty.R().Delete(baseURL + "/v2/repo7/manifests/" + digest.String())
So(err, ShouldBeNil)
So(resp.StatusCode(), ShouldEqual, 400)
So(resp.StatusCode(), ShouldEqual, 404)
// check/get by tag
resp, err = resty.R().Head(baseURL + "/v2/repo7/manifests/test:1.0")

View file

@ -462,10 +462,11 @@ func (is *ImageStore) DeleteImageManifest(repo string, reference string) error {
return errors.ErrRepoNotFound
}
// as per spec "reference" can only be a digest and not a tag
_, err := godigest.Parse(reference)
if err != nil {
is.log.Error().Err(err).Msg("invalid reference")
return errors.ErrManifestNotFound
return errors.ErrBadManifest
}
buf, err := ioutil.ReadFile(path.Join(dir, "index.json"))