summaryrefslogtreecommitdiff
path: root/app/controllers/projects/registry/tags_controller.rb
blob: d689cade3abaf8793929375038c5e50911f7a022 (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
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),
                      notice: 'Registry tag has been removed successfully!'
        else
          redirect_to project_container_registry_path(@project),
                      alert: 'Failed to remove registry tag!'
        end
      end

      private

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

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