summaryrefslogtreecommitdiff
path: root/app/controllers/projects/container_registry_controller.rb
blob: d1f4649720715948af5bdf97f986125ab56fd4b9 (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
29
30
31
32
33
34
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
    @tags = container_registry_repository.tags
  end

  def destroy
    url = namespace_project_container_registry_index_path(project.namespace, project)

    if tag.delete
      redirect_to url
    else
      redirect_to url, alert: 'Failed to remove tag'
    end
  end

  private

  def verify_registry_enabled
    render_404 unless Gitlab.config.registry.enabled
  end

  def container_registry_repository
    @container_registry_repository ||= project.container_registry_repository
  end

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