From 8ff60f9138203f74a63257bbd0e3e9b1decaacff Mon Sep 17 00:00:00 2001 From: Ramkumar Chinchani Date: Wed, 25 Mar 2020 11:22:52 -0700 Subject: [PATCH 1/2] conformance: fix error msg for DELETE MANIFEST --- Ran 27 of 27 Specs in 0.120 seconds SUCCESS! -- 27 Passed | 0 Failed | 0 Pending | 0 Skipped PASS --- --- pkg/api/routes.go | 5 ++++- pkg/compliance/v1_0_0/check.go | 2 +- pkg/storage/storage.go | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/api/routes.go b/pkg/api/routes.go index 75e0b2ee..718b21d4 100644 --- a/pkg/api/routes.go +++ b/pkg/api/routes.go @@ -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) diff --git a/pkg/compliance/v1_0_0/check.go b/pkg/compliance/v1_0_0/check.go index 4f0af291..c5f0dea2 100644 --- a/pkg/compliance/v1_0_0/check.go +++ b/pkg/compliance/v1_0_0/check.go @@ -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") diff --git a/pkg/storage/storage.go b/pkg/storage/storage.go index 7da82df1..8e486565 100644 --- a/pkg/storage/storage.go +++ b/pkg/storage/storage.go @@ -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")) From b141d4ff9b4be41525da42a4e86d774acfca6fc3 Mon Sep 17 00:00:00 2001 From: Ramkumar Chinchani Date: Wed, 25 Mar 2020 13:21:55 -0700 Subject: [PATCH 2/2] lint: relax agressive linter settings --- .bazel/golangcilint.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.bazel/golangcilint.yaml b/.bazel/golangcilint.yaml index 1775a4a0..5fb65e21 100644 --- a/.bazel/golangcilint.yaml +++ b/.bazel/golangcilint.yaml @@ -9,3 +9,8 @@ linters: output: format: colored-line-number + +linters-settings: + dupl: + # tokens count to trigger issue, 150 by default + threshold: 200