Add status to get container repository(ies) REST API response
What does this MR do and why?
The status
attribute of container repositories is already included
in the response of the ContainerRepositoryDetails
GraphQL API, but
they are not part of the equivalent REST APIs. This status
attribute is currently used to determine the status of the async
deletion for a given repository. The lack of this attribute in the
REST API has been identified as a problem for some users in
#427032 (closed).
This change adds the status
field to the response for
GET /registry/repositories/:id
and
GET /projects/:id/registry/repositories
endpoints.
The status
attribute is already part of the registry/repository
schema (source), and this is already tested here and here.
Related to #427032 (closed).
How to set up and validate locally
- Find or create a container repository through the Rails console:
ContainerRepository.first
ContainerRepository Load (2.3ms) SELECT "container_repositories".* FROM "container_repositories" ORDER BY "container_repositories"."id" ASC LIMIT 1 /*application:console,db_config_name:main,console_hostname:Joaos-MBP.lan,console_username:jpereira,line:(pry):1:in `__pry__'*/
=> #<ContainerRepository:0x000000016904d9f8
id: 1,
project_id: 2,
name: "repo-b",
created_at: Tue, 17 Oct 2023 17:07:39.490503000 UTC +00:00,
updated_at: Wed, 29 Nov 2023 16:11:29.494802000 UTC +00:00,
status: nil,
# ...
- Set its
status
to e.g.delete_scheduled
:
ContainerRepository.first.update! status: 0
- Grab a PAT with
api
orread_registry
permissions and make a call against the API:
❯ http -F gdk.test:3000/api/v4/registry/repositories/1 PRIVATE-TOKEN:"glpat-foo"
{
"cleanup_policy_started_at": null,
"created_at": "2023-10-17T17:07:39.490Z",
"delete_api_path": "http://gdk.test:3000/api/v4/projects/2/registry/repositories/1",
"id": 1,
"location": "registry.test:5000/gitlab-org/gitlab-test/repo-b",
"name": "repo-b",
"path": "gitlab-org/gitlab-test/repo-b",
"project_id": 2,
"status": "delete_scheduled"
}
❯ http -F gdk.test:3000/api/v4/projects/2/registry/repositories PRIVATE-TOKEN:"glpat-foo"
[
{
"cleanup_policy_started_at": null,
"created_at": "2023-10-17T17:07:39.490Z",
"id": 1,
"location": "registry.test:5000/gitlab-org/gitlab-test/repo-b",
"name": "repo-b",
"path": "gitlab-org/gitlab-test/repo-b",
"project_id": 2,
"status": "delete_scheduled"
}
]
Notice the status
attribute.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.