Add moving origin repository to GitlabAPIClient
⛰ Overview
The endpoint PATCH /gitlab/v1/repositories/<path>/ has been extended to allow moving the origin repository. Previously in #423995 (closed), we have allowed the renaming of projects with container repository tags. With the new updates to the endpoint, we can also now allow renaming the group where the project belongs or transferring the project or group within the same top-level namespace.
This issue aims to tackle the first step to add this feature. In this issue, we update ContainerRegistry::GitlabAPIClient to have a new method that we can then use in #475001 (closed).
We will use the API endpoint, PATCH /gitlab/v1/repositories/<path>/ (docs), in a new method that would:
- Accept the path and new namespace
- Send in the path and the namespace to the endpoint
In addition to that, we also need to support a new token type with the following permissions:
-
pull/pushaccess to the origin repository path -
pullaccess on all sub-repositories of the origin repository path -
pushaccess to the destination path (NEW)
🚵 Implementation Plan
- Add a new token in
ContainerRegistryAuthenticationServicethat contains the necessary permissions - Add new class method in
ContainerRegistry::GitlabApiClientto move the base repository. It can useContainerRegistry::GitlabApiClient.rename_base_repository_path. - Update
ContainerRegistry::GitlabApiClient.rename_base_repository_pathto accept namespace. Onlynameornamespaceshould be present at one time.