Skip to content

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/push access to the origin repository path
  • pull access on all sub-repositories of the origin repository path
  • push access to the destination path (NEW)

🚵 Implementation Plan

  1. Add a new token in ContainerRegistryAuthenticationService that contains the necessary permissions
  2. Add new class method in ContainerRegistry::GitlabApiClient to move the base repository. It can use ContainerRegistry::GitlabApiClient.rename_base_repository_path.
  3. Update ContainerRegistry::GitlabApiClient.rename_base_repository_path to accept namespace. Only name or namespace should be present at one time.
Edited by Adie (she/her)