Commit fbf82bf4 authored by Stan Hu's avatar Stan Hu Committed by Winnie Hellmann

Fix inability to delete container registry tags

Because container registry tags can have periods, the addition of the `.json`
format caused ambiguity. Since the tag name regex is greedy, it would attempt
to locate an image named `foo.json` instead of `foo`.

Closes #39260
parent 5717a1de
...@@ -4,7 +4,7 @@ class ContainerTagEntity < Grape::Entity ...@@ -4,7 +4,7 @@ class ContainerTagEntity < Grape::Entity
expose :name, :location, :revision, :short_revision, :total_size, :created_at expose :name, :location, :revision, :short_revision, :total_size, :created_at
expose :destroy_path, if: -> (*) { can_destroy? } do |tag| expose :destroy_path, if: -> (*) { can_destroy? } do |tag|
project_registry_repository_tag_path(project, tag.repository, tag.name, format: :json) project_registry_repository_tag_path(project, tag.repository, tag.name)
end end
private private
......
...@@ -281,10 +281,15 @@ constraints(ProjectUrlConstrainer.new) do ...@@ -281,10 +281,15 @@ constraints(ProjectUrlConstrainer.new) do
namespace :registry do namespace :registry do
resources :repository, only: [] do resources :repository, only: [] do
# We default to JSON format in the controller to avoid ambiguity.
# `latest.json` could either be a request for a tag named `latest`
# in JSON format, or a request for tag named `latest.json`.
scope format: false do
resources :tags, only: [:index, :destroy], resources :tags, only: [:index, :destroy],
constraints: { id: Gitlab::Regex.container_registry_tag_regex } constraints: { id: Gitlab::Regex.container_registry_tag_regex }
end end
end end
end
resources :milestones, constraints: { id: /\d+/ } do resources :milestones, constraints: { id: /\d+/ } do
member do member do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment