Skip to content

Add referrers to container repository tags in GraphQL API

What does this MR do and why?

Adds referrer as a property of container repository tags in the GraphQL API. Referrers are used to link container artifacts back to their corresponding tag.

Example:

query($id: ContainerRepositoryID!, $n: String) {
  containerRepository(id: $id) {
    tags(name: $n, referrers: true) {
      edges {
        node {
            canDelete
            createdAt
            digest
            location
            name
            path
            referrers {
                artifactType
                digest
            }
            revision
            shortRevision
            totalSize
        }
      }
    }
  }
}

Note: referrers: true is needed to signal the Gitlab API client to request referrers from the container registry; otherwise, referrers will not be returned by the registry (see container-registry#1531).

Example response
[
    {
        "node": {
            "canDelete": true,
            "createdAt": "2023-12-20T20:09:08+00:00",
            "digest": "sha256:1234567892",
            "location": "127.0.0.1:5000/namespace1/project-1/test_image_1:latest",
            "name": "latest",
            "path": "namespace1/project-1/test_image_1:latest",
            "referrers": [
                {
                    "artifactType": "application/vnd.example+type",
                    "digest": "sha256:57d3be92c2f857566ecc7f9306a80021c0a7fa631e0ef5146957235aea859961"
                },
                {
                    "artifactType": "application/vnd.example+type+2",
                    "digest": "sha256:01db72e42d61b8d2183d53475814cce2bfb9c8a254e97539a852441979cd5c90"
                }
            ],
            "revision": "3332132331",
            "shortRevision": "333213233",
            "totalSize": "1234509876"
        }
    }
]

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #426984 (closed)

Edited by Aaron Huntsman

Merge request reports