Commit a13dddee authored by rpereira2's avatar rpereira2

I18n error strings in metrics dashboard code

Internationalize error strings in metrics dashboard processing stages.
parent 0a5d4f9b
......@@ -80,7 +80,7 @@ module Metrics
def fetch_dashboard
uid = GrafanaUidParser.new(grafana_url, project).parse
raise DashboardProcessingError.new('Dashboard uid not found') unless uid
raise DashboardProcessingError.new(_('Dashboard uid not found')) unless uid
response = client.get_dashboard(uid: uid)
......@@ -89,7 +89,7 @@ module Metrics
def fetch_datasource(dashboard)
name = DatasourceNameParser.new(grafana_url, dashboard).parse
raise DashboardProcessingError.new('Datasource name not found') unless name
raise DashboardProcessingError.new(_('Datasource name not found')) unless name
response = client.get_datasource(name: name)
......@@ -115,7 +115,7 @@ module Metrics
def parse_json(json)
Gitlab::Json.parse(json, symbolize_names: true)
rescue JSON::ParserError
raise DashboardProcessingError.new('Grafana response contains invalid json')
raise DashboardProcessingError.new(_('Grafana response contains invalid json'))
end
end
......
......@@ -39,7 +39,7 @@ module Metrics
end
def invalid_embed_json!(message)
raise DashboardProcessingError.new("Parsing error for param :embed_json. #{message}")
raise DashboardProcessingError.new(_("Parsing error for param :embed_json. %{message}") % { message: message })
end
end
end
......
......@@ -28,13 +28,13 @@ module Gitlab
when :admin
admin_url(metric)
when :group
error!('Group is required when cluster_type is :group') unless params[:group]
error!(_('Group is required when cluster_type is :group')) unless params[:group]
group_url(metric)
when :project
error!('Project is required when cluster_type is :project') unless project
error!(_('Project is required when cluster_type is :project')) unless project
project_url(metric)
else
error!('Unrecognized cluster type')
error!(_('Unrecognized cluster type'))
end
end
......@@ -73,8 +73,8 @@ module Gitlab
end
def verify_params
raise Errors::DashboardProcessingError.new('Cluster is required for Stages::ClusterEndpointInserter') unless params[:cluster]
raise Errors::DashboardProcessingError.new('Cluster type must be specificed for Stages::ClusterEndpointInserter') unless params[:cluster_type]
raise Errors::DashboardProcessingError.new(_('Cluster is required for Stages::ClusterEndpointInserter')) unless params[:cluster]
raise Errors::DashboardProcessingError.new(_('Cluster type must be specificed for Stages::ClusterEndpointInserter')) unless params[:cluster_type]
end
end
end
......
......@@ -20,20 +20,20 @@ module Gitlab
when DashboardProcessingError
error(error.message, :unprocessable_entity)
when NOT_FOUND_ERROR
error("#{dashboard_path} could not be found.", :not_found)
error(_("%{dashboard_path} could not be found.") % { dashboard_path: dashboard_path }, :not_found)
when PanelNotFoundError
error(error.message, :not_found)
when ::Grafana::Client::Error
error(error.message, :service_unavailable)
when MissingIntegrationError
error('Proxy support for this API is not available currently', :bad_request)
error(_('Proxy support for this API is not available currently'), :bad_request)
else
raise error
end
end
def panels_not_found!(opts)
raise PanelNotFoundError.new("No panels matching properties #{opts}")
raise PanelNotFoundError.new(_("No panels matching properties %{opts}") % { opts: opts })
end
end
end
......
......@@ -6,7 +6,7 @@ module Gitlab
module Stages
class MetricEndpointInserter < BaseStage
def transform!
raise Errors::DashboardProcessingError.new('Environment is required for Stages::MetricEndpointInserter') unless params[:environment]
raise Errors::DashboardProcessingError.new(_('Environment is required for Stages::MetricEndpointInserter')) unless params[:environment]
for_metrics do |metric|
metric[:prometheus_endpoint_path] = endpoint_for_metric(metric)
......
......@@ -326,6 +326,9 @@ msgstr[1] ""
msgid "%{count} related %{pluralized_subject}: %{links}"
msgstr ""
msgid "%{dashboard_path} could not be found."
msgstr ""
msgid "%{days} days until tags are automatically removed"
msgstr ""
......@@ -4669,9 +4672,15 @@ msgstr ""
msgid "Cluster does not exist"
msgstr ""
msgid "Cluster is required for Stages::ClusterEndpointInserter"
msgstr ""
msgid "Cluster level"
msgstr ""
msgid "Cluster type must be specificed for Stages::ClusterEndpointInserter"
msgstr ""
msgid "ClusterIntegration| %{custom_domain_start}More information%{custom_domain_end}."
msgstr ""
......@@ -7070,6 +7079,9 @@ msgstr ""
msgid "Dashboard"
msgstr ""
msgid "Dashboard uid not found"
msgstr ""
msgid "DashboardProjects|All"
msgstr ""
......@@ -7094,6 +7106,9 @@ msgstr ""
msgid "Data is still calculating..."
msgstr ""
msgid "Datasource name not found"
msgstr ""
msgid "Date"
msgstr ""
......@@ -8555,6 +8570,9 @@ msgstr ""
msgid "Environment does not have deployments"
msgstr ""
msgid "Environment is required for Stages::MetricEndpointInserter"
msgstr ""
msgid "Environment is required for Stages::VariableEndpointInserter"
msgstr ""
......@@ -10961,6 +10979,9 @@ msgstr ""
msgid "Grafana URL"
msgstr ""
msgid "Grafana response contains invalid json"
msgstr ""
msgid "GrafanaIntegration|API Token"
msgstr ""
......@@ -11078,6 +11099,9 @@ msgstr ""
msgid "Group info:"
msgstr ""
msgid "Group is required when cluster_type is :group"
msgstr ""
msgid "Group maintainers can register group runners in the %{link}"
msgstr ""
......@@ -15062,6 +15086,9 @@ msgstr ""
msgid "No other labels with such name or description"
msgstr ""
msgid "No panels matching properties %{opts}"
msgstr ""
msgid "No parent group"
msgstr ""
......@@ -15988,6 +16015,9 @@ msgstr ""
msgid "Parent epic is not present."
msgstr ""
msgid "Parsing error for param :embed_json. %{message}"
msgstr ""
msgid "Part of merge request changes"
msgstr ""
......@@ -17293,6 +17323,9 @@ msgstr ""
msgid "Project has too many %{label_for_message} to search"
msgstr ""
msgid "Project is required when cluster_type is :project"
msgstr ""
msgid "Project members"
msgstr ""
......@@ -18205,6 +18238,9 @@ msgstr ""
msgid "Provider"
msgstr ""
msgid "Proxy support for this API is not available currently"
msgstr ""
msgid "Pseudonymizer data collection"
msgstr ""
......@@ -24203,6 +24239,9 @@ msgstr ""
msgid "Unreachable"
msgstr ""
msgid "Unrecognized cluster type"
msgstr ""
msgid "Unresolve"
msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment