Add mediaType as a field to ContainerRepository::Tag
What does this MR do and why?
Our container registry API returns a media_type
attribute for a tag (doc). In this MR, we add media_type
to the fields that we fetch and assign to a tag when we instantiate it from the container registry API.
Issue Link: #463789 (closed)
How to set up and validate locally
⛰ Prerequisites:
i. Metadata Database
Ensure that the metadata database is enabled and available. We are querying an API that is only available if the metadata database is enabled. In the Rails Console: bin/rails c
:
ContainerRegistry::GitlabApiClient.supports_gitlab_api?
#=> true
Note: Run this in a separate window where GITLAB_SIMULATE_SAAS=1
has not been exported. This function returns true as long as it is SAAS even if the API is not really available.
Gitlab.com?
should return true
ii. For now, we only allow this feature if it is on Gitlab.com. To test this locally, you may simulate a SaaS instance with:
export GITLAB_SIMULATE_SAAS=1
gdk start
iii. A container repository with tags or feel free to push a fresh one.
☀ Local Testing
- Open your GraphQL local explorer: http://gdk.test:3000/-/graphql-explorer
- Query the tags including the
mediaType
field. Replace<repository-id>
with theContainerRepository#id
of your local container repository.
query {
containerRepository(id: "gid://gitlab/ContainerRepository/<repository-id>") {
id
tags(first: 5) {
nodes {
name
publishedAt
mediaType
}
}
}
}
Results (your local results might differ):
{
"data": {
"containerRepository": {
"id": "gid://gitlab/ContainerRepository/4",
"tags": {
"nodes": [
{
"name": "aa",
"publishedAt": "2024-06-07T08:58:53+00:00",
"mediaType": "application/vnd.docker.distribution.manifest.v2+json"
}
]
}
}
}
}
Related to #463789 (closed)