summaryrefslogtreecommitdiff
path: root/app/controllers/projects/registry
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-03-31 13:56:07 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-03-31 13:56:07 +0200
commit00319e595ab52906d12ef027a10e08ac92ea1337 (patch)
tree4e915cbd81ac0cfd8a8a246950c905d8b915363a /app/controllers/projects/registry
parentf32d269cfa08f280c0d0dd86c4b50c4dcfb7409f (diff)
downloadgitlab-ce-00319e595ab52906d12ef027a10e08ac92ea1337.tar.gz
Move code related to registry to multiple controllers
Diffstat (limited to 'app/controllers/projects/registry')
-rw-r--r--app/controllers/projects/registry/application_controller.rb8
-rw-r--r--app/controllers/projects/registry/repositories_controller.rb36
-rw-r--r--app/controllers/projects/registry/tags_controller.rb20
3 files changed, 31 insertions, 33 deletions
diff --git a/app/controllers/projects/registry/application_controller.rb b/app/controllers/projects/registry/application_controller.rb
index 8710c219553..a56f9c58726 100644
--- a/app/controllers/projects/registry/application_controller.rb
+++ b/app/controllers/projects/registry/application_controller.rb
@@ -3,8 +3,14 @@ module Projects
class ApplicationController < Projects::ApplicationController
layout 'project'
- before_action :verify_registry_enabled
+ before_action :verify_registry_enabled!
before_action :authorize_read_container_image!
+
+ private
+
+ def verify_registry_enabled!
+ render_404 unless Gitlab.config.registry.enabled
+ end
end
end
end
diff --git a/app/controllers/projects/registry/repositories_controller.rb b/app/controllers/projects/registry/repositories_controller.rb
index b953d5b3378..e3e30176b30 100644
--- a/app/controllers/projects/registry/repositories_controller.rb
+++ b/app/controllers/projects/registry/repositories_controller.rb
@@ -8,47 +8,19 @@ module Projects
end
def destroy
- if tag
- delete_tag
- else
- 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_image
if image.destroy
- redirect_to registry_url
+ redirect_to project_container_registry_path(@project)
else
- redirect_to registry_url, alert: 'Failed to remove image'
+ redirect_to project_container_registry_path(@project),
+ alert: 'Failed to remove images repository!'
end
end
- def delete_tag
- if tag.delete
- image.destroy if image.tags.empty?
- redirect_to registry_url
- else
- redirect_to registry_url, alert: 'Failed to remove tag'
- end
- end
+ private
def image
@image ||= project.container_repositories.find_by(id: params[:id])
end
-
- def tag
- @tag ||= image.tag(params[:tag]) if params[:tag].present?
- end
end
end
end
diff --git a/app/controllers/projects/registry/tags_controller.rb b/app/controllers/projects/registry/tags_controller.rb
index e40489f67ad..8f0a1aff394 100644
--- a/app/controllers/projects/registry/tags_controller.rb
+++ b/app/controllers/projects/registry/tags_controller.rb
@@ -2,6 +2,26 @@ module Projects
module Registry
class TagsController < ::Projects::Registry::ApplicationController
before_action :authorize_update_container_image!, only: [:destroy]
+
+ def destroy
+ if tag.delete
+ redirect_to project_container_registry_path(@project)
+ else
+ redirect_to project_container_registry_path(@project),
+ alert: 'Failed to remove repository tag!'
+ end
+ end
+
+ private
+
+ def repository
+ @image ||= project.container_repositories
+ .find_by(id: params[:repository_id])
+ end
+
+ def tag
+ @tag ||= repository.tag(params[:id]) if params[:id].present?
+ end
end
end
end