diff options
Diffstat (limited to 'app/services/incident_management/pager_duty')
-rw-r--r-- | app/services/incident_management/pager_duty/create_incident_issue_service.rb | 34 | ||||
-rw-r--r-- | app/services/incident_management/pager_duty/process_webhook_service.rb | 3 |
2 files changed, 6 insertions, 31 deletions
diff --git a/app/services/incident_management/pager_duty/create_incident_issue_service.rb b/app/services/incident_management/pager_duty/create_incident_issue_service.rb index ee0feb49e0d..0c9ca2c0add 100644 --- a/app/services/incident_management/pager_duty/create_incident_issue_service.rb +++ b/app/services/incident_management/pager_duty/create_incident_issue_service.rb @@ -12,46 +12,30 @@ module IncidentManagement def execute return forbidden unless webhook_available? - issue = create_issue - return error(issue.errors.full_messages.to_sentence, issue) unless issue.valid? - - success(issue) + create_incident end private alias_method :incident_payload, :params - def create_issue - label_result = find_or_create_incident_label - - # Create an unlabelled issue if we couldn't create the label - # due to a race condition. - # See https://gitlab.com/gitlab-org/gitlab-foss/issues/65042 - extra_params = label_result.success? ? { label_ids: [label_result.payload[:label].id] } : {} - - Issues::CreateService.new( + def create_incident + ::IncidentManagement::Incidents::CreateService.new( project, current_user, title: issue_title, - description: issue_description, - **extra_params + description: issue_description ).execute end def webhook_available? - Feature.enabled?(:pagerduty_webhook, project) && - incident_management_setting.pagerduty_active? + incident_management_setting.pagerduty_active? end def forbidden ServiceResponse.error(message: 'Forbidden', http_status: :forbidden) end - def find_or_create_incident_label - ::IncidentManagement::CreateIncidentLabelService.new(project, current_user).execute - end - def issue_title incident_payload['title'] end @@ -59,14 +43,6 @@ module IncidentManagement def issue_description Gitlab::IncidentManagement::PagerDuty::IncidentIssueDescription.new(incident_payload).to_s end - - def success(issue) - ServiceResponse.success(payload: { issue: issue }) - end - - def error(message, issue = nil) - ServiceResponse.error(payload: { issue: issue }, message: message) - end end end end diff --git a/app/services/incident_management/pager_duty/process_webhook_service.rb b/app/services/incident_management/pager_duty/process_webhook_service.rb index 5dd3186694a..fd8252f75fb 100644 --- a/app/services/incident_management/pager_duty/process_webhook_service.rb +++ b/app/services/incident_management/pager_duty/process_webhook_service.rb @@ -39,8 +39,7 @@ module IncidentManagement end def webhook_setting_active? - Feature.enabled?(:pagerduty_webhook, project) && - incident_management_setting.pagerduty_active? + incident_management_setting.pagerduty_active? end def valid_token?(token) |