debian-mirror-gitlab/app/services/prometheus/adapter_service.rb

36 lines
1,004 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2018-03-27 19:54:05 +05:30
module Prometheus
class AdapterService
def initialize(project, deployment_platform = nil)
@project = project
@deployment_platform = if deployment_platform
deployment_platform
else
project.deployment_platform
end
end
attr_reader :deployment_platform, :project
def prometheus_adapter
@prometheus_adapter ||= if service_prometheus_adapter.can_query?
service_prometheus_adapter
else
cluster_prometheus_adapter
end
end
def service_prometheus_adapter
project.find_or_initialize_service('prometheus')
end
def cluster_prometheus_adapter
2019-09-30 21:07:59 +05:30
application = deployment_platform&.cluster&.application_prometheus
2018-03-27 19:54:05 +05:30
2019-09-30 21:07:59 +05:30
application if application&.available?
2018-03-27 19:54:05 +05:30
end
end
end