diff options
author | Stan Hu <stanhu@gmail.com> | 2017-10-18 16:35:37 -0700 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2017-10-21 23:32:05 +0300 |
commit | fbf82bf47c8e854bcc0ce64728a30c7cbc04bfa1 (patch) | |
tree | ed17595dec94b03a84f92211d064b0bf83139886 | |
parent | 5717a1de82967c38cf638d6063e61dd0494c1344 (diff) | |
download | gitlab-ce-fbf82bf47c8e854bcc0ce64728a30c7cbc04bfa1.tar.gz |
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
-rw-r--r-- | app/serializers/container_tag_entity.rb | 2 | ||||
-rw-r--r-- | config/routes/project.rb | 9 |
2 files changed, 8 insertions, 3 deletions
diff --git a/app/serializers/container_tag_entity.rb b/app/serializers/container_tag_entity.rb index 26a68c43807..8f1488e6cbb 100644 --- a/app/serializers/container_tag_entity.rb +++ b/app/serializers/container_tag_entity.rb @@ -4,7 +4,7 @@ class ContainerTagEntity < Grape::Entity expose :name, :location, :revision, :short_revision, :total_size, :created_at 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 private diff --git a/config/routes/project.rb b/config/routes/project.rb index 7f0e056c884..d05fe11f233 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -281,8 +281,13 @@ constraints(ProjectUrlConstrainer.new) do namespace :registry do resources :repository, only: [] do - resources :tags, only: [:index, :destroy], - constraints: { id: Gitlab::Regex.container_registry_tag_regex } + # 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], + constraints: { id: Gitlab::Regex.container_registry_tag_regex } + end end end |