summaryrefslogtreecommitdiff
path: root/app/controllers/projects/container_registry_controller.rb
blob: 82c621b29e432c195e43ed91115a7df3e278f64e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class Projects::ContainerRegistryController < Projects::ApplicationController
  before_action :authorize_read_container_registry!
  before_action :authorize_update_container_registry!, only: [:destroy]
  before_action :tag, except: [:index]
  layout 'project'

  def index
    @tags = container_registry_repository.tags
  end

  def destroy
    if tag.delete
      redirect_to namespace_project_container_registry_index_path(project.namespace, project)
    else
      redirect_to namespace_project_container_registry_index_path(project.namespace, project), alert: 'Failed to remove tag'
    end
  end

  private

  def container_registry_repository
    @container_registry_repository ||= project.container_registry_repository
  end

  def tag
    @tag ||= container_registry_repository[params[:id]]
  end
end