Skip to content

feat: implement OCI Distribution Spec v1.1 referrers API - #4828

Open
lemonprogis wants to merge 6 commits into
distribution:mainfrom
lemonprogis:referrers-api
Open

lemonprogis wants to merge 6 commits into
distribution:mainfrom
lemonprogis:referrers-api

Conversation

@lemonprogis

Copy link
Copy Markdown

Summary

Implements the OCI Distribution Spec v1.1 referrers API (GET /v2/{name}/referrers/{digest}), completing the work started in #3834 and #4483.

This builds on the storage-layer subject linking by @brackendawson and @alistair (cherry-picked from #4483) and adds the read-side endpoint that was left as TODO.

What's included

From #4483 (storage layer — @brackendawson, @alistair):

  • Parse subject and artifactType fields on OCI manifest and index PUT
  • Create referrer link files on the filesystem under _referrers/
  • Validate subject.mediaType is a manifest type

New (referrers API endpoint):

  • Register GET /v2/{name}/referrers/{digest} route
  • Return an OCI Image Index (application/vnd.oci.image.index.v1+json) with descriptors for all manifests referencing the subject
  • Enrich each descriptor with mediaType, artifactType, and annotations from the manifest blob per spec
  • Resolve artifactType per spec: manifest field → config.mediaType fallback
  • Support ?artifactType= query parameter filtering with OCI-Filters-Applied response header
  • Return empty index (not 404) when no referrers exist
  • Enumerate referrer links from the filesystem storage layout

Tests

  • TestReferrersAPI — end-to-end test covering:
    • Push subject manifest, push artifact manifest with subject reference
    • Query referrers (unfiltered) — verify digest, mediaType, artifactType
    • Query with matching artifactType filter — verify filtering + header
    • Query with non-matching filter — verify empty result
    • Query for digest with no referrers — verify empty index
  • All existing tests pass (handlers, storage, manifest suites)

Spec references

Related PRs

teambush1 and others added 5 commits March 26, 2026 14:51
Signed-off-by: Alistair Bush <[email protected]>
Co-authored-by: Alistair Bush <[email protected]>
Co-authored-by: Bracken Dawson <[email protected]>
Signed-off-by: lemonprogis <[email protected]>
Signed-off-by: Edward Briggler <[email protected]>
Signed-off-by: Alistair Bush <[email protected]>
Signed-off-by: lemonprogis <[email protected]>
Signed-off-by: Edward Briggler <[email protected]>
Signed-off-by: Alistair Bush <[email protected]>

Signed-off-by: lemonprogis <[email protected]>
Signed-off-by: Edward Briggler <[email protected]>
Signed-off-by: Alistair Bush <[email protected]>
Signed-off-by: lemonprogis <[email protected]>
Signed-off-by: Edward Briggler <[email protected]>
…{digest})

Completes the referrers API per OCI Distribution Spec v1.1 by adding
the read-side endpoint on top of the storage-layer subject linking from
the previous commits.

- Register GET /v2/{name}/referrers/{digest} route
- Implement referrersHandler returning an OCI Image Index response
- Enumerate referrer links from the filesystem storage layer
- Enrich descriptors with mediaType, artifactType, and annotations
  from the manifest blob per spec requirements
- Support ?artifactType= query parameter filtering with
  OCI-Filters-Applied response header
- Return empty index (not 404) when no referrers exist
- Add comprehensive TestReferrersAPI covering unfiltered listing,
  artifact type filtering, non-matching filters, and empty results

Signed-off-by: lemonprogis <[email protected]>
Signed-off-by: Edward Briggler <[email protected]>
- Rename emptyJsonDescriptor to emptyJSONDescriptor (staticcheck ST1003)
- Regenerate docs/content/spec/api.md from template to include the
  referrers route

Signed-off-by: Edward Briggler <[email protected]>
Signed-off-by: lemonprogis <[email protected]>
@lemonprogis

Copy link
Copy Markdown
Author

@milosgajdos thank you for kicking off the additional checks. I saw the failures from validation and fixed those.

@milosgajdos

Copy link
Copy Markdown
Member

I dont think we'll smack it into the immediate release (i.e. the one we are planning soon), but the one after sure.

@lemonprogis

Copy link
Copy Markdown
Author

@milosgajdos understood. This will be a great enhancement for what we're doing in air-gapped deployments. Where can I read up on release cadences? Is that in CNCF slack? cc @joonas for visibility

@milosgajdos

Copy link
Copy Markdown
Member

There is no such thing as release cadence; Im more or less one of the few maintainers who does this in my free time, free of charge...you'll have to be patient, alas.

@lemonprogis

Copy link
Copy Markdown
Author

Good day @milosgajdos! Is there an update on when this could get merged in and when 3.2.0 will be made available?

@ramizpolic

Copy link
Copy Markdown

can we help here to get it merged? we really like the project and from the benchmark and usage side, it checks all the boxes. we just need the OCI v1.1 to be able to use it.

@lemonprogis

Copy link
Copy Markdown
Author

@thaJeztah and @milosgajdos wanted to bump this again 🙇

@milosgajdos

Copy link
Copy Markdown
Member

I'd like to get this into the next either minor or major release but we first need to cut the patch one

@andrewg-xyz

Copy link
Copy Markdown

@lemonprogis I realize the changes are near ready, but wanted to offer a few additions. I ran into these scenarios while running distribution spec conformance testing

I broke apart the changes to make it easier to review and cherry-pick as desired.

  1. Set OCI-Subject on successful subject-bearing OCI manifest and index pushes diffs
  2. Persist the manifest before creating its referrer link, including OCI indexes diffs
  3. Concurrency testing diffs
  4. Publish subject-bearing manifest revisions only after referrer-link creation succeeds, so a failed push is not fetch-able by digest diffs

Happy to follow up or assist, with these changes I believe distribution-spec conformance testing related to referrers will pass.

@lemonprogis

lemonprogis commented Nov 24, 2026 •

Copy link
Copy Markdown
Author

@andrewg-xyz I'd love to take these commits. Could you add a Signed-off-by line on these commits so CI will pass after I bring them in?

@andrewg-xyz

Copy link
Copy Markdown

@andrewg-xyz I'd love to take these commits. Could you add a Signed-off-by line on these commits so CI will pass after I bring them in?

✅

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: References support

6 participants