Add partial tags delete support to the API for bulk removal of tags at the project level
Summary
Currently, when using the API for bulk removal of tags at the project level, there is a limitation in the implementation: tags are deleted only if other tags pointing to the same digest are also selected for destruction.
Example:
- A container repository with tags
fooandbarpointing to the same digest. - Calling
DELETE /projects/:id/registry/repositories/:repository_id/tags?name_regex=foowill not do anything.
The proper expectation would be:
-
foois deleted but notbar.
Improvements
A safe way to implement tags have been implemented, see !16886 (merged).
We can update the API side to use this new implementation and thus, properly delete tags even if they share a common digest with tags that are not selected for destruction.
Risks
- Delete tags that are not in the selection filters.
Involved components
-
Projects::ContainerRepository::CleanupTagsServiceshould useProjects::ContainerRepository::DeleteTagsServiceinstead of callingContainerRegistry::Tag#unsafe_delete. - Investigate if it would be worth to merge
Projects::ContainerRepository::CleanupTagsServiceandProjects::ContainerRepository::DeleteTagsServiceinto a single service accepting several way to select tags (by array of names and/or by filters)
Edited by David Fernandez