Skip to content

Commit

Permalink
Return OCI Index content-type for referrers response (#1762)
Browse files Browse the repository at this point in the history
Signed-off-by: Josh Dolitsky <josh@dolit.ski>
  • Loading branch information
jdolitsky committed Jul 31, 2023
1 parent b850480 commit ea19b57
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/registry/manifest.go
Expand Up @@ -437,6 +437,7 @@ func (m *manifests) handleReferrers(resp http.ResponseWriter, req *http.Request)
}
msg, _ := json.Marshal(&im)
resp.Header().Set("Content-Length", fmt.Sprint(len(msg)))
resp.Header().Set("Content-Type", string(types.OCIImageIndex))
resp.WriteHeader(http.StatusOK)
io.Copy(resp, bytes.NewReader([]byte(msg)))
return nil
Expand Down
9 changes: 9 additions & 0 deletions pkg/registry/registry_test.go
Expand Up @@ -446,6 +446,9 @@ func TestCalls(t *testing.T) {
"foo/manifests/image": "foo",
"foo/manifests/points-to-image": "{\"subject\": {\"digest\": \"sha256:" + sha256String("foo") + "\"}}",
},
Header: map[string]string{
"Content-Type": "application/vnd.oci.image.index.v1+json",
},
},
{
Description: "fetch references, subject pointing elsewhere",
Expand All @@ -456,6 +459,9 @@ func TestCalls(t *testing.T) {
"foo/manifests/image": "foo",
"foo/manifests/points-to-image": "{\"subject\": {\"digest\": \"sha256:" + sha256String("nonexistant") + "\"}}",
},
Header: map[string]string{
"Content-Type": "application/vnd.oci.image.index.v1+json",
},
},
{
Description: "fetch references, no results",
Expand All @@ -465,6 +471,9 @@ func TestCalls(t *testing.T) {
Manifests: map[string]string{
"foo/manifests/image": "foo",
},
Header: map[string]string{
"Content-Type": "application/vnd.oci.image.index.v1+json",
},
},
{
Description: "fetch references, missing repo",
Expand Down

0 comments on commit ea19b57

Please sign in to comment.