From 8ba9c2bd6d10c74529a0e2e6bb894c34614966f1 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Thu, 21 Sep 2017 12:21:50 +0200 Subject: Add ContainerTag and ContainerRepository frontend API --- app/serializers/container_tag_entity.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 app/serializers/container_tag_entity.rb (limited to 'app/serializers/container_tag_entity.rb') diff --git a/app/serializers/container_tag_entity.rb b/app/serializers/container_tag_entity.rb new file mode 100644 index 00000000000..ec1fc349586 --- /dev/null +++ b/app/serializers/container_tag_entity.rb @@ -0,0 +1,23 @@ +class ContainerTagEntity < Grape::Entity + include RequestAwareEntity + + expose :name, :location, :revision, :total_size, :created_at + + expose :destroy_path, if: -> (*) { can_destroy? } do |tag| + project_registry_repository_tag_path(project, tag.repository, tag.name, format: :json) + end + + private + + alias_method :tag, :object + + def project + request.project + end + + def can_destroy? + # TODO: We check permission against @project, not tag, + # as tag is no AR object that is attached to project + can?(request.current_user, :update_container_image, project) + end +end -- cgit v1.2.3