debian-mirror-gitlab/app/controllers/projects/registry/tags_controller.rb

48 lines
1.1 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
module Projects
module Registry
class TagsController < ::Projects::Registry::ApplicationController
before_action :authorize_update_container_image!, only: [:destroy]
2018-03-17 18:26:18 +05:30
def index
respond_to do |format|
format.json do
render json: ContainerTagsSerializer
.new(project: @project, current_user: @current_user)
.with_pagination(request, response)
.represent(tags)
end
end
end
2017-08-17 22:00:37 +05:30
def destroy
if tag.delete
2018-03-17 18:26:18 +05:30
respond_to do |format|
format.json { head :no_content }
end
2017-08-17 22:00:37 +05:30
else
2018-03-17 18:26:18 +05:30
respond_to do |format|
format.json { head :bad_request }
end
2017-08-17 22:00:37 +05:30
end
end
private
2018-03-17 18:26:18 +05:30
def tags
Kaminari::PaginatableArray.new(image.tags, limit: 15)
end
2017-08-17 22:00:37 +05:30
def image
@image ||= project.container_repositories
.find(params[:repository_id])
end
def tag
@tag ||= image.tag(params[:id])
end
end
end
end