BigW Consortium Gitlab

container_registry_controller.rb 842 Bytes
Newer Older
Kamil Trzcinski committed
1
class Projects::ContainerRegistryController < Projects::ApplicationController
2
  before_action :verify_registry_enabled
3 4
  before_action :authorize_read_container_image!
  before_action :authorize_update_container_image!, only: [:destroy]
Kamil Trzcinski committed
5 6 7
  layout 'project'

  def index
8
    @tags = container_registry_repository.tags
Kamil Trzcinski committed
9 10 11
  end

  def destroy
Kamil Trzcinski committed
12 13
    url = namespace_project_container_registry_index_path(project.namespace, project)

Kamil Trzcinski committed
14
    if tag.delete
Kamil Trzcinski committed
15
      redirect_to url
Kamil Trzcinski committed
16
    else
Kamil Trzcinski committed
17
      redirect_to url, alert: 'Failed to remove tag'
Kamil Trzcinski committed
18 19 20 21 22
    end
  end

  private

23 24 25 26
  def verify_registry_enabled
    render_404 unless Gitlab.config.registry.enabled
  end

27 28
  def container_registry_repository
    @container_registry_repository ||= project.container_registry_repository
Kamil Trzcinski committed
29 30 31
  end

  def tag
32
    @tag ||= container_registry_repository.tag(params[:id])
Kamil Trzcinski committed
33 34
  end
end