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