Add an OCI registry client for tags and manifests
What does this MR do and why?
Adds Gitlab::PackageMetadata::Oci::Client with tags and manifest. tags follows Link: rel="next" pages up to 50, and refuses a next link to another origin. It takes an optional stop check and returns nil when the check answers true between pages. On a 401 the client answers the bearer challenge with the parser from MR 1 and retries with the token alone.
With credentials configured, they go only to the registry's own scheme, host and port, or to a token_hosts entry over HTTPS on the port it names (443 without one). A challenge naming any other realm, or the right host on another port, raises an error before any token request. The error names the host and port. The token request does not follow redirects.
A tag, manifest or token response larger than 20 MiB (MAX_RESPONSE_BYTES, the JSON parser's own limit) is refused. tags refuses a repository that lists more than 50,000 tags in total.
Safe alone: nothing calls the client yet.
Part 3 of 7. Previous: feature/pmdb-oci-2-settings. Next: feature/pmdb-oci-4-blobs.
sequenceDiagram
participant C as Client
participant R as Registry
participant T as Token service
C->>R: GET tags/list
R-->>C: 401 with Bearer challenge and realm
Note over C: with credentials, realm must be the registry origin, or a token_hosts host and port over HTTPS
C->>T: token request, redirects not followed
T-->>C: token
C->>R: retry with the token onlyRelated to #642401
How to set up and validate locally
bundle exec rspec ee/spec/lib/gitlab/package_metadata/oci/client_spec.rbMR acceptance checklist
- The specs that cover this slice pass at
a85144c7eb: 583 examples in 13 spec files, 0 failures. - RuboCop reports no offenses on the changed files.
An AI coding assistant wrote this change. The assistant also ran RuboCop on the changed files and the specs above on a self-managed GitLab development instance on a test VM.