diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-11 18:09:37 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-11 18:09:37 +0300 |
commit | a210c43e0aca0311cc1d3d381763b25979ec72dc (patch) | |
tree | 0325d173da7a6e7bd6c2cdf450d0aa1c4e142d0f /app/serializers/environment_entity.rb | |
parent | c9687bdf58e9d4a9c3942f587bd4841f42e3b5de (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/serializers/environment_entity.rb')
-rw-r--r-- | app/serializers/environment_entity.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/app/serializers/environment_entity.rb b/app/serializers/environment_entity.rb index 74d6806e83f..d9af7af8a8b 100644 --- a/app/serializers/environment_entity.rb +++ b/app/serializers/environment_entity.rb @@ -47,6 +47,22 @@ class EnvironmentEntity < Grape::Entity environment.available? && can?(current_user, :stop_environment, environment) end + expose :logs_path, if: -> (*) { can_read_pod_logs? } do |environment| + project_logs_path(environment.project, environment_name: environment.name) + end + + expose :logs_api_path, if: -> (*) { can_read_pod_logs? } do |environment| + if environment.elastic_stack_available? + elasticsearch_project_logs_path(environment.project, environment_name: environment.name, format: :json) + else + k8s_project_logs_path(environment.project, environment_name: environment.name, format: :json) + end + end + + expose :enable_advanced_logs_querying, if: -> (*) { can_read_pod_logs? } do |environment| + environment.elastic_stack_available? + end + private alias_method :environment, :object @@ -63,6 +79,10 @@ class EnvironmentEntity < Grape::Entity can?(current_user, :update_environment, environment) end + def can_read_pod_logs? + can?(current_user, :read_pod_logs, environment.project) + end + def cluster_platform_kubernetes? deployment_platform && deployment_platform.is_a?(Clusters::Platforms::Kubernetes) end |