-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Description
regshape referrer list currently requires a digest reference (registry/repo@sha256:...) and rejects tag references with exit code 2. This is because the OCI Referrers API endpoint (GET /v2/<name>/referrers/<digest>) requires a digest.
However, users most commonly work with tags rather than digests. The command should accept tag references and automatically resolve them to a digest via a HEAD request before querying the referrers API.
Proposed Behavior
When --image-ref contains a tag reference (e.g. registry/repo:v1.0), the command should:
- Issue
HEAD /v2/<name>/manifests/<tag>to resolve the tag to a digest (via theDocker-Content-Digestresponse header) - Use the resolved digest to call
GET /v2/<name>/referrers/<digest> - Proceed as normal with the referrer results
When --image-ref already contains a digest, behavior is unchanged.
Acceptance Criteria
-
regshape referrer list -i registry/repo:tagresolves the tag and lists referrers -
regshape referrer list -i registry/repo@sha256:...continues to work as before (no regression) - Tag resolution failure (e.g. tag not found) produces a clear error with exit code 1
- The
--json,--all,--artifact-type, and--outputflags work with tag references - Help text and
--image-refdescription updated to reflect tag support - Unit tests cover: tag resolution happy path, tag not found error, digest passthrough unchanged
- CLI spec (
specs/cli/referrer.md) updated to document tag support
Files to Create/Modify
CLI layer
src/regshape/cli/referrer.py— Remove the digest-only guard; add tag-to-digest resolution usinghead_manifestbefore callinglist_referrers/list_referrers_all
Library layer
No changes needed — libs/referrers/operations.py already accepts a digest string, and libs/manifests/operations.py already provides head_manifest(client, repo, reference, accept) which returns (digest, media_type, size).
Tests
src/regshape/tests/test_referrer_cli.py— Add tests for tag resolution, updatetest_tag_reference_rejected_with_exit_code_2to expect success instead of rejection
Specs
specs/cli/referrer.md— Update accepted formats table and description
Implementation Notes
The tag-to-digest resolution requires a single additional HEAD request. The head_manifest function from libs/manifests already handles this:
from regshape.libs.manifests import head_manifest
from regshape.libs.models.mediatype import ALL_MANIFEST_MEDIA_TYPES
accept = ",".join(sorted(ALL_MANIFEST_MEDIA_TYPES))
digest, _, _ = head_manifest(client, repo, tag, accept)
# Now use digest for the referrers API callThe guard block that currently rejects tags:
if not reference.startswith("sha256:") and not reference.startswith("sha512:"):
emit_error(...)should be replaced with a resolution step that calls head_manifest to obtain the digest.
References
specs/cli/referrer.md— Current CLI specspecs/operations/referrers.md— Referrers operations spec- OCI Distribution Spec: Referrers API requires a digest in the URL path