From ed5add1c2f001c9bd54e664b32f212de172eca6a Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Fri, 10 Apr 2020 18:09:32 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- app/graphql/resolvers/metrics/dashboard_resolver.rb | 21 +++++++++++++++++++++ app/graphql/types/environment_type.rb | 4 ++++ app/graphql/types/metrics/dashboard_type.rb | 15 +++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 app/graphql/resolvers/metrics/dashboard_resolver.rb create mode 100644 app/graphql/types/metrics/dashboard_type.rb (limited to 'app/graphql') diff --git a/app/graphql/resolvers/metrics/dashboard_resolver.rb b/app/graphql/resolvers/metrics/dashboard_resolver.rb new file mode 100644 index 00000000000..05d82ca0f46 --- /dev/null +++ b/app/graphql/resolvers/metrics/dashboard_resolver.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module Resolvers + module Metrics + class DashboardResolver < Resolvers::BaseResolver + argument :path, GraphQL::STRING_TYPE, + required: true, + description: "Path to a file which defines metrics dashboard eg: 'config/prometheus/common_metrics.yml'" + + type Types::Metrics::DashboardType, null: true + + alias_method :environment, :object + + def resolve(**args) + return unless environment + + ::PerformanceMonitoring::PrometheusDashboard.find_for(project: environment.project, user: context[:current_user], path: args[:path], options: { environment: environment }) + end + end + end +end diff --git a/app/graphql/types/environment_type.rb b/app/graphql/types/environment_type.rb index c165c0ddc61..34a90006d03 100644 --- a/app/graphql/types/environment_type.rb +++ b/app/graphql/types/environment_type.rb @@ -15,5 +15,9 @@ module Types field :state, GraphQL::STRING_TYPE, null: false, description: 'State of the environment, for example: available/stopped' + + field :metrics_dashboard, Types::Metrics::DashboardType, null: true, + description: 'Metrics dashboard schema for the environment', + resolver: Resolvers::Metrics::DashboardResolver end end diff --git a/app/graphql/types/metrics/dashboard_type.rb b/app/graphql/types/metrics/dashboard_type.rb new file mode 100644 index 00000000000..11e834013ca --- /dev/null +++ b/app/graphql/types/metrics/dashboard_type.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Types + module Metrics + # rubocop: disable Graphql/AuthorizeTypes + # Authorization is performed at environment level + class DashboardType < ::Types::BaseObject + graphql_name 'MetricsDashboard' + + field :path, GraphQL::STRING_TYPE, null: true, + description: 'Path to a file with the dashboard definition' + end + # rubocop: enable Graphql/AuthorizeTypes + end +end -- cgit v1.2.1