diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /app/services/incident_management/pager_duty/create_incident_issue_service.rb | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'app/services/incident_management/pager_duty/create_incident_issue_service.rb')
-rw-r--r-- | app/services/incident_management/pager_duty/create_incident_issue_service.rb | 34 |
1 files changed, 5 insertions, 29 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 |