From de24bd937f20a66628fdacf4d658eb95df0b3769 Mon Sep 17 00:00:00 2001 From: Ramkumar Chinchani <45800463+rchincha@users.noreply.github.com> Date: Sat, 22 Jul 2023 16:25:02 -0700 Subject: [PATCH] fix(conformance): OCI-Filters-Applied should return a literal (#1640) * fix(conformance): OCI-Filters-Applied should return a literal https://github.com/opencontainers/distribution-spec/issues/448 Should only indicate what filter-type was applied and not what exact values it was filtered on. Signed-off-by: Ramkumar Chinchani * ci(conformance): point to temporary repo Revert this commit once upstream changes have been merged Signed-off-by: Ramkumar Chinchani --------- Signed-off-by: Ramkumar Chinchani --- .github/workflows/oci-conformance-action.yml | 4 ++-- pkg/api/controller_test.go | 4 ++-- pkg/api/routes.go | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/oci-conformance-action.yml b/.github/workflows/oci-conformance-action.yml index 021dc6ef..ff0a9e39 100644 --- a/.github/workflows/oci-conformance-action.yml +++ b/.github/workflows/oci-conformance-action.yml @@ -38,8 +38,8 @@ jobs: with: # TODO: change to upstream once the foloowing PR is merged: # https://github.com/opencontainers/distribution-spec/pull/436 - repository: opencontainers/distribution-spec - ref: main + repository: rchincha/distribution-spec + ref: fix-ref path: distribution-spec - name: build conformance binary from main run: | diff --git a/pkg/api/controller_test.go b/pkg/api/controller_test.go index 038a241b..d9c0d301 100644 --- a/pkg/api/controller_test.go +++ b/pkg/api/controller_test.go @@ -5924,7 +5924,7 @@ func TestArtifactReferences(t *testing.T) { So(err, ShouldBeNil) So(resp.StatusCode(), ShouldEqual, http.StatusOK) So(resp.Header().Get("Content-Type"), ShouldEqual, ispec.MediaTypeImageIndex) - So(resp.Header().Get("OCI-Filters-Applied"), ShouldEqual, artifactType) + So(resp.Header().Get("OCI-Filters-Applied"), ShouldEqual, "artifactType") resp, err = resty.R().SetQueryParams(map[string]string{"artifactType": artifactType + ",otherArtType"}).Get(baseURL + fmt.Sprintf("/v2/%s/referrers/%s", repoName, @@ -5932,7 +5932,7 @@ func TestArtifactReferences(t *testing.T) { So(err, ShouldBeNil) So(resp.StatusCode(), ShouldEqual, http.StatusOK) So(resp.Header().Get("Content-Type"), ShouldEqual, ispec.MediaTypeImageIndex) - So(resp.Header().Get("OCI-Filters-Applied"), ShouldEqual, artifactType+",otherArtType") + So(resp.Header().Get("OCI-Filters-Applied"), ShouldEqual, "artifactType") }) }) }) diff --git a/pkg/api/routes.go b/pkg/api/routes.go index e01e0194..3c809a77 100644 --- a/pkg/api/routes.go +++ b/pkg/api/routes.go @@ -624,7 +624,8 @@ func (rh *RouteHandler) GetReferrers(response http.ResponseWriter, request *http } if len(artifactTypes) > 0 { - response.Header().Set("OCI-Filters-Applied", strings.Join(artifactTypes, ",")) + // currently, the only filter supported and on this end-point + response.Header().Set("OCI-Filters-Applied", "artifactType") } zcommon.WriteData(response, http.StatusOK, ispec.MediaTypeImageIndex, out)