Skip to content

Extract portable OCI metadata transformations - #813

Open
simonchrz wants to merge 1 commit into
git-pkgs:mainfrom
simonchrz:refactor/metadata-oci
Open

simonchrz wants to merge 1 commit into
git-pkgs:mainfrom
simonchrz:refactor/metadata-oci

Conversation

@simonchrz

Copy link
Copy Markdown
Contributor

Part of #501, the OCI step.

As in #612 for npm, the OCI distribution metadata transformations move out of internal/handler into internal/metadata/oci:

  • RewriteLink, which points the targets of a tag list or referrers Link header that lead back into the upstream registry's API at the same endpoint on the proxy, keeping their query and the ns route the client is on
  • Accepts, AcceptsIndex, Names, NormalizeAccept and IsIndexMediaType, the manifest Accept negotiation, with the media type constants and DefaultManifestAccept
  • ManifestRefs, which lists the digests an index or image manifest references, with the Manifest, Descriptor and Platform types and DigestPattern

OCI has no cooldown or denylist filtering of tag lists, so this step is these pure parts only. LinkOptions carries the proxy and registry URLs, the request path and the ns value explicitly. The package doesn't depend on handler.Proxy. The code moves as it was, so responses and cache keys are the same.

What stays in the handler: fetching, token auth, coalescing, caching and cache keys, the checks on cached manifests and upstream responses, path parsing, and the image tag and manifest records. The handler's functions stay as thin wrappers and the manifest types as aliases, so the handler tests run unchanged against the real routes.

Portability: GOOS=wasip1 GOARCH=wasm go build ./internal/metadata/oci works. The package imports only the standard library; imports_test.go fails on any non-standard import and on net, net/http, log/slog or database/sql.

New tests in internal/metadata/oci cover the Link rewrite for relative, query-only and absolute targets, other hosts and schemes, paths outside /v2/, unparseable URLs, the ns route and several targets; Accept matching with wildcards, q values, parameters and specificity; normalisation; the index helpers; and manifest references, including duplicates, bad digests and the limit. They were mutation-checked, as was the handler's wiring. There are no benchmarks for these paths to compare. go test ./... and golangci-lint run ./... pass.

Part of git-pkgs#501. The tag list and referrers Link rewrite, manifest Accept
negotiation and the references a manifest names move out of
internal/handler into internal/metadata/oci, which takes its inputs
explicitly and builds for wasip1. The handler keeps fetching, token
auth, coalescing and caching, with its functions as thin wrappers.
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 27 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 59612d01-09f2-4c22-8254-84f829eb7430
Commits

Reviewing files that changed from the base of the PR and between be51120 and e627236.

Files selected for processing: 10

  • internal/handler/container.go
  • internal/handler/container_image_refs.go
  • internal/handler/container_manifest.go
  • internal/handler/container_mirror.go
  • internal/handler/container_tags.go
  • internal/metadata/oci/accept.go
  • internal/metadata/oci/imports_test.go
  • internal/metadata/oci/link.go
  • internal/metadata/oci/manifest.go
  • internal/metadata/oci/metadata_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant