debian-mirror-gitlab/app/serializers/cluster_entity.rb

40 lines
1.1 KiB
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
class ClusterEntity < Grape::Entity
include RequestAwareEntity
2020-05-24 23:13:21 +05:30
expose :cluster_type
expose :enabled
expose :environment_scope
2021-01-03 14:25:43 +05:30
expose :id
expose :namespace_per_environment
2020-05-24 23:13:21 +05:30
expose :name
expose :nodes
2020-06-23 00:09:42 +05:30
expose :provider_type
2018-03-17 18:26:18 +05:30
expose :status_name, as: :status
expose :status_reason
expose :applications, using: ClusterApplicationEntity
2020-05-24 23:13:21 +05:30
expose :path do |cluster|
Clusters::ClusterPresenter.new(cluster).show_path # rubocop: disable CodeReuse/Presenter
end
2020-07-28 23:09:34 +05:30
2022-07-16 23:28:13 +05:30
expose :gitlab_managed_apps_logs_path, if: -> (*) { logging_enabled? } do |cluster|
2020-07-28 23:09:34 +05:30
Clusters::ClusterPresenter.new(cluster, current_user: request.current_user).gitlab_managed_apps_logs_path # rubocop: disable CodeReuse/Presenter
end
2020-10-24 23:57:45 +05:30
expose :kubernetes_errors do |cluster|
2022-05-07 20:08:51 +05:30
Clusters::KubernetesErrorEntity.new(cluster)
2020-10-24 23:57:45 +05:30
end
2020-11-24 15:15:51 +05:30
2022-07-16 23:28:13 +05:30
expose :enable_advanced_logs_querying, if: -> (*) { logging_enabled? } do |cluster|
2021-06-08 01:23:25 +05:30
cluster.elastic_stack_available?
2020-11-24 15:15:51 +05:30
end
2022-07-16 23:28:13 +05:30
private
def logging_enabled?
Feature.enabled?(:monitor_logging, object.project)
end
2018-03-17 18:26:18 +05:30
end