summaryrefslogtreecommitdiff
path: root/app/serializers/deployment_cluster_entity.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/serializers/deployment_cluster_entity.rb')
-rw-r--r--app/serializers/deployment_cluster_entity.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/app/serializers/deployment_cluster_entity.rb b/app/serializers/deployment_cluster_entity.rb
new file mode 100644
index 00000000000..98736472b62
--- /dev/null
+++ b/app/serializers/deployment_cluster_entity.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class DeploymentClusterEntity < Grape::Entity
+ include RequestAwareEntity
+
+ # Until data is copied over from deployments.cluster_id, this entity must represent Deployment instead of DeploymentCluster
+ # https://gitlab.com/gitlab-org/gitlab/issues/202628
+
+ expose :name do |deployment|
+ deployment.cluster.name
+ end
+
+ expose :path, if: -> (deployment) { can?(request.current_user, :read_cluster, deployment.cluster) } do |deployment|
+ deployment.cluster.present(current_user: request.current_user).show_path
+ end
+
+ expose :kubernetes_namespace, if: -> (deployment) { can?(request.current_user, :read_cluster, deployment.cluster) } do |deployment|
+ deployment.kubernetes_namespace
+ end
+end