summaryrefslogtreecommitdiff
path: root/app/controllers/projects/container_registry_controller.rb
blob: 94f7580f0eace9fd61be8963e989e5daef6219f2 (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_image!
  before_action :authorize_update_image!, 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[params[:id]]
  end
end