Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-03-31 14:08:09 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-03-31 14:08:09 +0300
commit41956773839ba010bb316e6bbe8d48c1ad7177de (patch)
tree324cf70115b9c0a6a2bfde69332234f760c53992 /app/controllers/projects/registry
parent4726ff9dbee74d00544c7eb1ea188ecdfe16d7e8 (diff)
Reorganize container repository controllers and views
Diffstat (limited to 'app/controllers/projects/registry')
-rw-r--r--app/controllers/projects/registry/application_controller.rb10
-rw-r--r--app/controllers/projects/registry/repositories_controller.rb54
-rw-r--r--app/controllers/projects/registry/tags_controller.rb7
3 files changed, 71 insertions, 0 deletions
diff --git a/app/controllers/projects/registry/application_controller.rb b/app/controllers/projects/registry/application_controller.rb
new file mode 100644
index 00000000000..8710c219553
--- /dev/null
+++ b/app/controllers/projects/registry/application_controller.rb
@@ -0,0 +1,10 @@
+module Projects
+ module Registry
+ class ApplicationController < Projects::ApplicationController
+ layout 'project'
+
+ before_action :verify_registry_enabled
+ before_action :authorize_read_container_image!
+ end
+ end
+end
diff --git a/app/controllers/projects/registry/repositories_controller.rb b/app/controllers/projects/registry/repositories_controller.rb
new file mode 100644
index 00000000000..b953d5b3378
--- /dev/null
+++ b/app/controllers/projects/registry/repositories_controller.rb
@@ -0,0 +1,54 @@
+module Projects
+ module Registry
+ class RepositoriesController < ::Projects::Registry::ApplicationController
+ before_action :authorize_update_container_image!, only: [:destroy]
+
+ def index
+ @images = project.container_repositories
+ 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
+ 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 registry_url
+ else
+ redirect_to registry_url, alert: 'Failed to remove tag'
+ end
+ end
+
+ 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
new file mode 100644
index 00000000000..e40489f67ad
--- /dev/null
+++ b/app/controllers/projects/registry/tags_controller.rb
@@ -0,0 +1,7 @@
+module Projects
+ module Registry
+ class TagsController < ::Projects::Registry::ApplicationController
+ before_action :authorize_update_container_image!, only: [:destroy]
+ end
+ end
+end