Add manifest detail and referrers reads to the AR client (S06 Phase 2 container manifest detail plan: step 12/15)

What does this MR do and why?

This is Step 12 of 15 in the "S06 Phase 2 container manifest detail" plan for GitLab Artifact Registry. It is backend-only: two new read methods on the Ruby Artifact Registry API client, plus one new value object. No GraphQL and no UI ship here; those arrive in Steps 13, 14, and 15.

The Artifact Registry HTTP API can serve a single container manifest by digest and can list the manifests that refer to it (the referrers list), but the Rails client (ee/lib/artifact_registry/client.rb) had neither read. It only had the manifests list and the by-digest DELETE. This MR adds the two reads so a future manifest-detail page can address its own manifest and its referrers in a bounded number of requests.

New methods:

  • ArtifactRegistry::Client#manifest(slug:, repository_name:, format:, image_id:, digest:)
  • ArtifactRegistry::Client#manifest_referrers(slug:, repository_name:, format:, image_id:, digest:, limit:, cursor:)

Both take the image id AND the digest, matching the existing delete_manifest signature rather than a shortened pair, because Artifact Registry keys the route on .../images/:image_id/manifests/:digest -- neither value alone reaches the manifest. This "manifest is addressed by two primitives at every boundary" is a named, accepted trade-off from the plan: the URL, the contract, and the existing delete signature already carry the pair.

Both guard to the container formats (docker, oci) the same way the existing manifests list read does, and both return nil for a missing manifest (a 404) rather than raising. On the single manifest read, a blank or dot-segment image id or digest resolves nil as well -- both are user-supplied deep-link values, so a malformed one lands on the same not-found outcome as a real 404 rather than raising, exposing no id-syntax oracle. This follows the single-artifact reads' rule rather than delete_manifest's.

New value object: ArtifactRegistry::ManifestDetail (ee/lib/artifact_registry/manifest_detail.rb), deliberately SEPARATE from the existing list-element ArtifactRegistry::Manifest, not a widening of it. The detail resource carries four arrays -- tags, children, parent_digests, annotations. On a list row the first three are served as a preview plus a count, and annotations is withheld outright; widening Manifest would give every list row readers for fields the list never sends and make a list row and a detail row indistinguishable by type. Keeping them apart also lets the later GraphQL step (13) present the detail through its own type with no presenter shim.

annotations is the one field whose null and empty readings mean different things and that Artifact Registry keeps apart on the wire: nil when the pushed manifest had no annotations key, an empty map {} when it had an empty one. The three arrays never null on the wire -- AR renders a nil or empty set as [] -- so a nil reader means the key was absent. That is what parent_digests and parents_count read today: S17 declares both but AR does not serve them yet (as of v2.54.0), gated on gitlab-org/ops/artifact-registry!2661 (merged); tags and children are served. The platform triple (architecture, os, os_variant) is nullable per value, not as a unit.

The detail read tolerates unknown fields (forward-compatible), and malformed shapes -- a non-Hash annotations, a non-Hash children entry, a non-string array member -- coerce rather than reaching a consumer as another type.

Not flag-gated: the client is not feature-flag-gated; its callers are. This code has no live caller yet (the GraphQL resolver arrives in Step 13), so nothing renders its output. No changelog trailer, since nothing user-visible ships, and no user-facing strings / i18n.

References

How to set up and validate locally

The value-object spec uses fast_spec_helper and the client spec uses spec_helper, so they cannot run in one rspec invocation. Run them separately. Each is expected to report 0 failures.

# value object: null-vs-empty for annotations, always-[] arrays, the platform triple,
# malformed-shape coercion (14 examples)
bundle exec rspec ee/spec/lib/artifact_registry/manifest_detail_spec.rb

# the two new client reads: both formats, 404 -> nil, malformed deep link -> nil, mapped errors,
# format and segment guards, path encoding, remote empty readings (36 examples)
bundle exec rspec ee/spec/lib/artifact_registry/client_spec.rb -e "Client#manifest " -e "Client#manifest_referrers"

Screenshots or screen recordings

No UI in this MR. It adds a backend client method pair and a value object only, so no screenshots apply.

Edited by Narendran

Merge request reports

Loading
Loading