summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorAndre Guedes <andrebsguedes@gmail.com>2017-01-25 10:24:50 -0200
committerAndre Guedes <andrebsguedes@gmail.com>2017-02-22 11:30:11 -0300
commit8294756fc110fdb84036e4ae097940410a8ad6de (patch)
treee1b2b85e8c97cce7392be80eba8592b836009d6b /app/controllers
parentea17df5c4c23890c48cd51af17e2517f04f7c88b (diff)
downloadgitlab-ce-8294756fc110fdb84036e4ae097940410a8ad6de.tar.gz
Improved readability in tag/image delete condition
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/projects/container_registry_controller.rb28
1 files changed, 17 insertions, 11 deletions
diff --git a/app/controllers/projects/container_registry_controller.rb b/app/controllers/projects/container_registry_controller.rb
index f656f86fcdb..4981e57ed22 100644
--- a/app/controllers/projects/container_registry_controller.rb
+++ b/app/controllers/projects/container_registry_controller.rb
@@ -9,31 +9,37 @@ class Projects::ContainerRegistryController < Projects::ApplicationController
end
def destroy
- url = namespace_project_container_registry_index_path(project.namespace, project)
-
if tag
- delete_tag(url)
+ delete_tag
else
- if image.destroy
- redirect_to url
- else
- redirect_to url, alert: 'Failed to remove image'
- end
+ delete_image
end
end
private
+ def registry_url
+ @registry_url ||= namespace_project_container_registry_index_path(project.namespace, project)
+ end
+
def verify_registry_enabled
render_404 unless Gitlab.config.registry.enabled
end
- def delete_tag(url)
+ def delete_image
+ if image.destroy
+ redirect_to registry_url
+ else
+ redirect_to registry_url, alert: 'Failed to remove image'
+ end
+ end
+
+ def delete_tag
if tag.delete
image.destroy if image.tags.empty?
- redirect_to url
+ redirect_to registry_url
else
- redirect_to url, alert: 'Failed to remove tag'
+ redirect_to registry_url, alert: 'Failed to remove tag'
end
end