diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /app/models/incident_management | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'app/models/incident_management')
-rw-r--r-- | app/models/incident_management/project_incident_management_setting.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/models/incident_management/project_incident_management_setting.rb b/app/models/incident_management/project_incident_management_setting.rb index bf57c5b883f..c79acdb685f 100644 --- a/app/models/incident_management/project_incident_management_setting.rb +++ b/app/models/incident_management/project_incident_management_setting.rb @@ -8,6 +8,15 @@ module IncidentManagement validate :issue_template_exists, if: :create_issue? + before_validation :ensure_pagerduty_token + + attr_encrypted :pagerduty_token, + mode: :per_attribute_iv, + key: ::Settings.attr_encrypted_db_key_base_truncated, + algorithm: 'aes-256-gcm', + encode: false, # No need to encode for binary column https://github.com/attr-encrypted/attr_encrypted#the-encode-encode_iv-encode_salt-and-default_encoding-options + encode_iv: false + def available_issue_templates Gitlab::Template::IssueTemplate.all(project) end @@ -30,5 +39,15 @@ module IncidentManagement Gitlab::Template::IssueTemplate.find(issue_template_key, project) rescue Gitlab::Template::Finders::RepoTemplateFinder::FileNotFoundError end + + def ensure_pagerduty_token + return unless pagerduty_active + + self.pagerduty_token ||= generate_pagerduty_token + end + + def generate_pagerduty_token + SecureRandom.hex + end end end |