summaryrefslogtreecommitdiff
path: root/app/controllers/projects/registry/tags_controller.rb
blob: 8f0a1aff394a48593f812ba8158693a3a9b1cf9e (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
module Projects
  module Registry
    class TagsController < ::Projects::Registry::ApplicationController
      before_action :authorize_update_container_image!, only: [:destroy]

      def destroy
        if tag.delete
          redirect_to project_container_registry_path(@project)
        else
          redirect_to project_container_registry_path(@project),
                      alert: 'Failed to remove repository tag!'
        end
      end

      private

      def repository
        @image ||= project.container_repositories
          .find_by(id: params[:repository_id])
      end

      def tag
        @tag ||= repository.tag(params[:id]) if params[:id].present?
      end
    end
  end
end