Skip to content

Add referrers data to internal tags API

Summary

In order to display signature information for images in the GitLab UI (&7856), Rails needs to be able to find the signatures associated with a tag (Blocked by #967 (closed)). To do this, we will update the list repository tags API to include referrer information (signatures are stored as referrers).

The data will take this shape:

[
  {
    "name": "0.1.0",
    "digest": "sha256:6c3c624b58dbbcd3c0dd82b4c53f04194d1247c6eebdaab7c610cf7d66709b3b",
    "media_type": "application/vnd.oci.image.manifest.v1+json",
    "size_bytes": 286734237,
    "created_at": "2022-06-07T12:10:12.412+00:00",
    "referrers": [
      {
        "artifactType": "application/vnd.dev.cosign.artifact.sig.v1+json",
        "digest": "sha256:eb110b254f038cd0d464b20de5070099a6f675b9d8eb7e5035d929540a041ab1"
      }
    ]
  },
  {
    "name": "latest",
    "digest": "sha256:6c3c624b58dbbcd3c0dd82b4c53f04194d1247c6eebdaab7c610cf7d66709b3b",
    "media_type": "application/vnd.oci.image.manifest.v1+json",
    "size_bytes": 286734237,
    "created_at": "2022-06-07T12:11:13.633+00:00",
    "updated_at": "2022-06-07T14:37:49.251+00:00"
  }
]

Implementation plan

  1. Find the refferers related to a list of tags
    1. On repositoryStore, add a method to query associated refferers. Ex: (*repositoryStore).bulkLoadAssociatedRefferers(ctx context.Context, tags []*models.TagDetail)
    2. Query for manifests where subject_manifest_id in (?) where ? is a list of tag.ManifestID for the given tags
    3. Read these manifests from the DB
    4. Iterate through tags and add the Referrer data for each
  2. Check the query param referrals=[true|false], pass this along to (*repositoryStore).TagsDetailPaginated as an argument
  3. On (*repositoryStore).TagsDetailPaginated, if referrals are requested, use tagStore.bulkLoadAssociatedRefferers(ctx, tags) to load associations before returning the tag details.
Edited by Brian Williams