Add additional parameters and return value to ContainerRegistry::GitlabApiClient#tags
Context 🌅
Today, we have the epic: Use new container registry API for listing repo... (&10208 - closed) that aims to implement the usage of the new API to list repository tags. After the investigation in #403314 (closed), the list repository tags API endpoint will be updated in container-registry#1012 (closed), container-registry#1000 (closed), and container-registry#1008 (closed) to support the functionalities we need in listing registry tags in the Gitlab UI.
After the three issues in the Container Registry is done, this issue aims to update the implementation of ContainerRegistry::GitlabApiClient#tags to support the additional parameters and return value of the list repository tags API endpoint.
ContainerRegistry::GitlabApiClient#tags is the main interface on the rails side to the /gitlab/v1/* endpoints.
Implementation Plan 🗺
Pagination can go both ways, both forward and backward. After the updates to the API endpoint, we would now be able to send in a before parameter in addition to the existing last and n parameters. The list repository tags endpoint will also support sorting and filtering by name so we can send in the extra parameters for these as well.
- We first update
ContainerRegistry::GitlabApiClient#tagsto receive the following new parameters and pass them to the/gitlab/v1/repositories/#{path}/tags/list/endpoint and update the tests accordingly.
-
before(to be added in Add ability to perform backward pagination in L... (container-registry#1012 - closed)) -
name(to be added in Add ability to filter tags by name (container-registry#1008 - closed)) -
sort(to be added in Add ability to sort and paginate repository tag... (container-registry#1000 - closed))
- We also update the tests for
ContainerRegistry::GitlabApiClient#tagsand assert that the pagination can receive bothnextandpreviousin thepaginationvalue of the result hash. Today, we only receive thenextlink, but in Add ability to perform backward pagination in L... (container-registry#1012 - closed), thepreviouslink will be added as well in the return value.
{
pagination: { next: { uri: URI(next_page_url) }, previous: { uri: URI(previous_page_url) } },
response_body: ::Gitlab::Json.parse(response.to_json)
}