summaryrefslogtreecommitdiff
path: root/app/models/integrations
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-04-13 15:08:16 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-04-13 15:08:16 +0000
commit907fd5d94ecec19ff7de4986e83e75e6fa082558 (patch)
tree5729bfd4ce7d552a0cb5e1a8f4b2437c68faf4b5 /app/models/integrations
parent0cb47d7129c3d5d7bc91d32222ca70d46cb976ca (diff)
downloadgitlab-ce-907fd5d94ecec19ff7de4986e83e75e6fa082558.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/integrations')
-rw-r--r--app/models/integrations/base_chat_notification.rb5
-rw-r--r--app/models/integrations/base_issue_tracker.rb13
-rw-r--r--app/models/integrations/buildkite.rb4
-rw-r--r--app/models/integrations/jira.rb6
-rw-r--r--app/models/integrations/pipelines_email.rb5
-rw-r--r--app/models/integrations/prometheus.rb6
6 files changed, 15 insertions, 24 deletions
diff --git a/app/models/integrations/base_chat_notification.rb b/app/models/integrations/base_chat_notification.rb
index d5b6357cb66..54bd595892f 100644
--- a/app/models/integrations/base_chat_notification.rb
+++ b/app/models/integrations/base_chat_notification.rb
@@ -35,8 +35,9 @@ module Integrations
validates :labels_to_be_notified_behavior, inclusion: { in: LABEL_NOTIFICATION_BEHAVIOURS }, allow_blank: true
def initialize_properties
- if properties.nil?
- self.properties = {}
+ super
+
+ if properties.empty?
self.notify_only_broken_pipelines = true
self.branches_to_be_notified = "default"
self.labels_to_be_notified_behavior = MATCH_ANY_LABEL
diff --git a/app/models/integrations/base_issue_tracker.rb b/app/models/integrations/base_issue_tracker.rb
index 458d0199e7a..bffe87c21ee 100644
--- a/app/models/integrations/base_issue_tracker.rb
+++ b/app/models/integrations/base_issue_tracker.rb
@@ -25,12 +25,15 @@ module Integrations
def handle_properties
# this has been moved from initialize_properties and should be improved
# as part of https://gitlab.com/gitlab-org/gitlab/issues/29404
- return unless properties
+ return unless properties.present?
+
+ safe_keys = data_fields.attributes.keys.grep_v(/encrypted/) - %w[id service_id created_at]
@legacy_properties_data = properties.dup
- data_values = properties.slice!('title', 'description')
+
+ data_values = properties.slice(*safe_keys)
data_values.reject! { |key| data_fields.changed.include?(key) }
- data_values.slice!(*data_fields.attributes.keys)
+
data_fields.assign_attributes(data_values) if data_values.present?
self.properties = {}
@@ -68,10 +71,6 @@ module Integrations
issue_url(iid)
end
- def initialize_properties
- {}
- end
-
# Initialize with default properties values
def set_default_data
return unless issues_tracker.present?
diff --git a/app/models/integrations/buildkite.rb b/app/models/integrations/buildkite.rb
index 90593d78a5d..b816f90ef52 100644
--- a/app/models/integrations/buildkite.rb
+++ b/app/models/integrations/buildkite.rb
@@ -27,12 +27,12 @@ module Integrations
end
# Since SSL verification will always be enabled for Buildkite,
- # we no longer needs to store the boolean.
+ # we no longer need to store the boolean.
# This is a stub method to work with deprecated API param.
# TODO: remove enable_ssl_verification after 14.0
# https://gitlab.com/gitlab-org/gitlab/-/issues/222808
def enable_ssl_verification=(_value)
- self.properties.delete('enable_ssl_verification') # Remove unused key
+ self.properties = properties.except('enable_ssl_verification') # Remove unused key
end
override :hook_url
diff --git a/app/models/integrations/jira.rb b/app/models/integrations/jira.rb
index b20efa55529..a800b9e5baa 100644
--- a/app/models/integrations/jira.rb
+++ b/app/models/integrations/jira.rb
@@ -94,10 +94,6 @@ module Integrations
!!URI(url).hostname&.end_with?(JIRA_CLOUD_HOST)
end
- def initialize_properties
- {}
- end
-
def data_fields
jira_tracker_data || self.build_jira_tracker_data
end
@@ -106,7 +102,7 @@ module Integrations
return unless reset_password?
data_fields.password = nil
- properties.delete('password') if properties
+ self.properties = properties.except('password')
end
def set_default_data
diff --git a/app/models/integrations/pipelines_email.rb b/app/models/integrations/pipelines_email.rb
index 6dc41958daa..f15482dc2e1 100644
--- a/app/models/integrations/pipelines_email.rb
+++ b/app/models/integrations/pipelines_email.rb
@@ -12,8 +12,9 @@ module Integrations
validate :number_of_recipients_within_limit, if: :validate_recipients?
def initialize_properties
- if properties.nil?
- self.properties = {}
+ super
+
+ if properties.blank?
self.notify_only_broken_pipelines = true
self.branches_to_be_notified = "default"
elsif !self.notify_only_default_branch.nil?
diff --git a/app/models/integrations/prometheus.rb b/app/models/integrations/prometheus.rb
index 2e275dab91b..d6aafe45ae9 100644
--- a/app/models/integrations/prometheus.rb
+++ b/app/models/integrations/prometheus.rb
@@ -32,12 +32,6 @@ module Integrations
scope :preload_project, -> { preload(:project) }
scope :with_clusters_with_cilium, -> { joins(project: [:clusters]).merge(Clusters::Cluster.with_available_cilium) }
- def initialize_properties
- if properties.nil?
- self.properties = {}
- end
- end
-
def show_active_box?
false
end