diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-03-31 13:08:09 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-03-31 13:08:09 +0200 |
commit | 41956773839ba010bb316e6bbe8d48c1ad7177de (patch) | |
tree | 324cf70115b9c0a6a2bfde69332234f760c53992 | |
parent | 4726ff9dbee74d00544c7eb1ea188ecdfe16d7e8 (diff) | |
download | gitlab-ce-41956773839ba010bb316e6bbe8d48c1ad7177de.tar.gz |
Reorganize container repository controllers and views
-rw-r--r-- | app/controllers/projects/container_registry_controller.rb | 53 | ||||
-rw-r--r-- | app/controllers/projects/registry/application_controller.rb | 10 | ||||
-rw-r--r-- | app/controllers/projects/registry/repositories_controller.rb | 54 | ||||
-rw-r--r-- | app/controllers/projects/registry/tags_controller.rb | 7 | ||||
-rw-r--r-- | app/views/projects/registry/repositories/_image.html.haml (renamed from app/views/projects/container_registry/_image.html.haml) | 0 | ||||
-rw-r--r-- | app/views/projects/registry/repositories/_tag.html.haml (renamed from app/views/projects/container_registry/_tag.html.haml) | 0 | ||||
-rw-r--r-- | app/views/projects/registry/repositories/index.html.haml (renamed from app/views/projects/container_registry/index.html.haml) | 0 | ||||
-rw-r--r-- | config/routes/project.rb | 5 |
8 files changed, 75 insertions, 54 deletions
diff --git a/app/controllers/projects/container_registry_controller.rb b/app/controllers/projects/container_registry_controller.rb deleted file mode 100644 index 8929bd0aa55..00000000000 --- a/app/controllers/projects/container_registry_controller.rb +++ /dev/null @@ -1,53 +0,0 @@ -class Projects::ContainerRegistryController < Projects::ApplicationController - before_action :verify_registry_enabled - before_action :authorize_read_container_image! - before_action :authorize_update_container_image!, only: [:destroy] - layout 'project' - - 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 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 diff --git a/app/views/projects/container_registry/_image.html.haml b/app/views/projects/registry/repositories/_image.html.haml index 64b11e375c6..64b11e375c6 100644 --- a/app/views/projects/container_registry/_image.html.haml +++ b/app/views/projects/registry/repositories/_image.html.haml diff --git a/app/views/projects/container_registry/_tag.html.haml b/app/views/projects/registry/repositories/_tag.html.haml index f7161e85428..f7161e85428 100644 --- a/app/views/projects/container_registry/_tag.html.haml +++ b/app/views/projects/registry/repositories/_tag.html.haml diff --git a/app/views/projects/container_registry/index.html.haml b/app/views/projects/registry/repositories/index.html.haml index 1b5d000e801..1b5d000e801 100644 --- a/app/views/projects/container_registry/index.html.haml +++ b/app/views/projects/registry/repositories/index.html.haml diff --git a/config/routes/project.rb b/config/routes/project.rb index 44b8ae7aedd..34f4bd917f7 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -219,7 +219,10 @@ constraints(ProjectUrlConstrainer.new) do end end - resources :container_registry, only: [:index, :destroy], constraints: { id: Gitlab::Regex.container_registry_reference_regex } + resources :container_registry, + controller: 'registry/repositories', + only: [:index, :destroy], + constraints: { id: Gitlab::Regex.container_registry_reference_regex } resources :milestones, constraints: { id: /\d+/ } do member do |