Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-30 12:08:55 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-30 12:08:55 +0300
commitbe37a0ee5e3e3dbb967266248f0f46f14a9931e2 (patch)
tree8fd575a36933fb847a6f92ff76d9c1ad908a3f7b /lib/gitlab/metrics
parent6305f1dc00870f6e0635e2e850538a00bbd00bda (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/metrics')
-rw-r--r--lib/gitlab/metrics/dashboard/service_selector.rb53
1 files changed, 21 insertions, 32 deletions
diff --git a/lib/gitlab/metrics/dashboard/service_selector.rb b/lib/gitlab/metrics/dashboard/service_selector.rb
index 5b6f25420e0..5a3007e4814 100644
--- a/lib/gitlab/metrics/dashboard/service_selector.rb
+++ b/lib/gitlab/metrics/dashboard/service_selector.rb
@@ -8,50 +8,39 @@ module Gitlab
module Metrics
module Dashboard
class ServiceSelector
- SERVICES = ::Metrics::Dashboard
-
class << self
include Gitlab::Utils::StrongMemoize
+ SERVICES = [
+ ::Metrics::Dashboard::CustomMetricEmbedService,
+ ::Metrics::Dashboard::GrafanaMetricEmbedService,
+ ::Metrics::Dashboard::DynamicEmbedService,
+ ::Metrics::Dashboard::DefaultEmbedService,
+ ::Metrics::Dashboard::SystemDashboardService,
+ ::Metrics::Dashboard::PodDashboardService,
+ ::Metrics::Dashboard::ProjectDashboardService
+ ].freeze
+
# Returns a class which inherits from the BaseService
- # class that can be used to obtain a dashboard.
+ # class that can be used to obtain a dashboard for
+ # the provided params.
# @return [Gitlab::Metrics::Dashboard::Services::BaseService]
def call(params)
- return SERVICES::CustomMetricEmbedService if custom_metric_embed?(params)
- return SERVICES::GrafanaMetricEmbedService if grafana_metric_embed?(params)
- return SERVICES::DynamicEmbedService if dynamic_embed?(params)
- return SERVICES::DefaultEmbedService if params[:embedded]
- return SERVICES::SystemDashboardService if system_dashboard?(params[:dashboard_path])
- return SERVICES::PodDashboardService if pod_dashboard?(params[:dashboard_path])
- return SERVICES::ProjectDashboardService if params[:dashboard_path]
-
- default_service
- end
+ service = services.find do |service_class|
+ service_class.valid_params?(params)
+ end
- private
-
- def default_service
- SERVICES::SystemDashboardService
+ service || default_service
end
- def system_dashboard?(filepath)
- SERVICES::SystemDashboardService.matching_dashboard?(filepath)
- end
-
- def pod_dashboard?(filepath)
- SERVICES::PodDashboardService.matching_dashboard?(filepath)
- end
-
- def custom_metric_embed?(params)
- SERVICES::CustomMetricEmbedService.valid_params?(params)
- end
+ private
- def grafana_metric_embed?(params)
- SERVICES::GrafanaMetricEmbedService.valid_params?(params)
+ def services
+ SERVICES
end
- def dynamic_embed?(params)
- SERVICES::DynamicEmbedService.valid_params?(params)
+ def default_service
+ ::Metrics::Dashboard::SystemDashboardService
end
end
end