2018-09-26 03:45:43 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-03-31 11:08:09 +00:00
|
|
|
module Projects
|
|
|
|
module Registry
|
|
|
|
class TagsController < ::Projects::Registry::ApplicationController
|
|
|
|
before_action :authorize_update_container_image!, only: [:destroy]
|
2017-03-31 11:56:07 +00:00
|
|
|
|
2017-09-21 10:21:50 +00:00
|
|
|
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-03-31 11:56:07 +00:00
|
|
|
def destroy
|
2017-10-02 20:53:14 +00:00
|
|
|
if tag.delete
|
|
|
|
respond_to do |format|
|
|
|
|
format.json { head :no_content }
|
|
|
|
end
|
|
|
|
else
|
|
|
|
respond_to do |format|
|
|
|
|
format.json { head :bad_request }
|
2017-09-21 10:21:50 +00:00
|
|
|
end
|
2017-03-31 11:56:07 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2017-09-21 10:21:50 +00:00
|
|
|
def tags
|
|
|
|
Kaminari::PaginatableArray.new(image.tags, limit: 15)
|
|
|
|
end
|
|
|
|
|
2017-04-06 08:23:51 +00:00
|
|
|
def image
|
2017-03-31 11:56:07 +00:00
|
|
|
@image ||= project.container_repositories
|
2017-04-05 12:18:42 +00:00
|
|
|
.find(params[:repository_id])
|
2017-03-31 11:56:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def tag
|
2017-04-06 08:23:51 +00:00
|
|
|
@tag ||= image.tag(params[:id])
|
2017-03-31 11:56:07 +00:00
|
|
|
end
|
2017-03-31 11:08:09 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|