diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-15 03:09:23 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-15 03:09:23 +0300 |
commit | 8aab944cc5e9b58ecc6f052db7cb8985a8a0ba51 (patch) | |
tree | 67f4c47cd3b3712daa0035bef27f04b04582e1b4 /app/models/incident_management | |
parent | f9cda7671cfb07795d9ea01a7117f7d6c6511d0d (diff) |
Add latest changes from gitlab-org/gitlab@master
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..61ca5183719 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 |