2020-07-28 23:09:34 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module OperationsHelper
|
|
|
|
include Gitlab::Utils::StrongMemoize
|
2021-09-30 23:02:18 +05:30
|
|
|
include IntegrationsHelper
|
2020-07-28 23:09:34 +05:30
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
def prometheus_integration
|
|
|
|
strong_memoize(:prometheus_integration) do
|
|
|
|
@project.find_or_initialize_integration(::Integrations::Prometheus.to_param)
|
2020-07-28 23:09:34 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def alerts_settings_data(disabled: false)
|
2021-09-04 01:27:46 +05:30
|
|
|
setting = project_incident_management_setting
|
2023-05-27 22:25:52 +05:30
|
|
|
templates = setting.available_issue_templates.map { |t| { value: t.key, text: t.name } }
|
2021-09-04 01:27:46 +05:30
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
{
|
2021-09-30 23:02:18 +05:30
|
|
|
'prometheus_activated' => prometheus_integration.manual_configuration?.to_s,
|
2022-01-26 12:08:38 +05:30
|
|
|
'prometheus_form_path' => scoped_integration_path(prometheus_integration, project: prometheus_integration.project, group: prometheus_integration.group),
|
2020-07-28 23:09:34 +05:30
|
|
|
'prometheus_reset_key_path' => reset_alerting_token_project_settings_operations_path(@project),
|
|
|
|
'prometheus_authorization_key' => @project.alerting_setting&.token,
|
2021-09-30 23:02:18 +05:30
|
|
|
'prometheus_api_url' => prometheus_integration.api_url,
|
2020-07-28 23:09:34 +05:30
|
|
|
'prometheus_url' => notify_project_prometheus_alerts_url(@project, format: :json),
|
2021-03-11 19:13:27 +05:30
|
|
|
'alerts_setup_url' => help_page_path('operations/incident_management/integrations.md', anchor: 'configuration'),
|
2020-07-28 23:09:34 +05:30
|
|
|
'alerts_usage_url' => project_alert_management_index_path(@project),
|
2021-01-29 00:20:46 +05:30
|
|
|
'disabled' => disabled.to_s,
|
|
|
|
'project_path' => @project.full_path,
|
2021-09-04 01:27:46 +05:30
|
|
|
'multi_integrations' => 'false',
|
|
|
|
'templates' => templates.to_json,
|
|
|
|
'create_issue' => setting.create_issue.to_s,
|
|
|
|
'issue_template_key' => setting.issue_template_key.to_s,
|
|
|
|
'send_email' => setting.send_email.to_s,
|
|
|
|
'auto_close_incident' => setting.auto_close_incident.to_s,
|
|
|
|
'pagerduty_reset_key_path' => reset_pagerduty_token_project_settings_operations_path(@project),
|
|
|
|
'operations_settings_endpoint' => project_settings_operations_path(@project)
|
2020-07-28 23:09:34 +05:30
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def operations_settings_data
|
|
|
|
setting = project_incident_management_setting
|
|
|
|
|
|
|
|
{
|
|
|
|
operations_settings_endpoint: project_settings_operations_path(@project),
|
|
|
|
pagerduty_active: setting.pagerduty_active.to_s,
|
|
|
|
pagerduty_token: setting.pagerduty_token.to_s,
|
2020-10-24 23:57:45 +05:30
|
|
|
pagerduty_webhook_url: project_incidents_integrations_pagerduty_url(@project, token: setting.pagerduty_token),
|
2020-07-28 23:09:34 +05:30
|
|
|
pagerduty_reset_key_path: reset_pagerduty_token_project_settings_operations_path(@project)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
OperationsHelper.prepend_mod_with('OperationsHelper')
|