diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-09 15:08:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-09 15:08:03 +0300 |
commit | cddaddb86bf6d4d277d206c42a9138a2d660ea56 (patch) | |
tree | 92da110e04602b7ea62835e41327e552150279f5 /app/serializers/review_app_setup_entity.rb | |
parent | 5afd8575506372dd64c238203bd05b4826f3ae2e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/serializers/review_app_setup_entity.rb')
-rw-r--r-- | app/serializers/review_app_setup_entity.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/serializers/review_app_setup_entity.rb b/app/serializers/review_app_setup_entity.rb new file mode 100644 index 00000000000..3a21fe24d9e --- /dev/null +++ b/app/serializers/review_app_setup_entity.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class ReviewAppSetupEntity < Grape::Entity + include RequestAwareEntity + + expose :can_setup_review_app?, as: :can_setup_review_app + + expose :all_clusters_empty?, as: :all_clusters_empty, if: -> (_, _) { project.can_setup_review_app? } do |project| + project.all_clusters_empty? + end + + expose :review_snippet, if: -> (_, _) { project.can_setup_review_app? } do |_| + YAML.safe_load(File.read(Rails.root.join('lib', 'gitlab', 'ci', 'snippets', 'review_app_default.yml'))).to_s + end + + private + + def current_user + request.current_user + end + + def project + object + end +end |