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