Reorganize container repository controllers and views
This commit is contained in:
parent
4726ff9dbe
commit
4195677383
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -0,0 +1,7 @@
|
|||
module Projects
|
||||
module Registry
|
||||
class TagsController < ::Projects::Registry::ApplicationController
|
||||
before_action :authorize_update_container_image!, only: [:destroy]
|
||||
end
|
||||
end
|
||||
end
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue