Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2017-09-21 13:21:50 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2017-09-21 13:21:50 +0300
commit8ba9c2bd6d10c74529a0e2e6bb894c34614966f1 (patch)
treec80ff14075e4d4bfc96828b3f980c6fd51429398 /app/serializers/container_tag_entity.rb
parentee3cf5d6f3d5a3631fa7e94a242f2dfe9b38a935 (diff)
Add ContainerTag and ContainerRepository frontend API
Diffstat (limited to 'app/serializers/container_tag_entity.rb')
-rw-r--r--app/serializers/container_tag_entity.rb23
1 files changed, 23 insertions, 0 deletions
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