Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-01-20 12:16:11 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-01-20 12:16:11 +0300
commitedaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch)
tree11f143effbfeba52329fb7afbd05e6e2a3790241 /lib/gitlab/config
parentd8a5691316400a0f7ec4f83832698f1988eb27c1 (diff)
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'lib/gitlab/config')
-rw-r--r--lib/gitlab/config/entry/configurable.rb3
-rw-r--r--lib/gitlab/config/entry/factory.rb5
-rw-r--r--lib/gitlab/config/entry/node.rb20
3 files changed, 26 insertions, 2 deletions
diff --git a/lib/gitlab/config/entry/configurable.rb b/lib/gitlab/config/entry/configurable.rb
index 6bf77ebaa5b..aa6c724c2a3 100644
--- a/lib/gitlab/config/entry/configurable.rb
+++ b/lib/gitlab/config/entry/configurable.rb
@@ -76,7 +76,7 @@ module Gitlab
private
# rubocop: disable CodeReuse/ActiveRecord
- def entry(key, entry, description: nil, default: nil, inherit: nil, reserved: nil, metadata: {})
+ def entry(key, entry, description: nil, default: nil, inherit: nil, reserved: nil, deprecation: nil, metadata: {})
entry_name = key.to_sym
raise ArgumentError, "Entry '#{key}' already defined in '#{name}'" if @nodes.to_h[entry_name]
@@ -85,6 +85,7 @@ module Gitlab
.with(default: default)
.with(inherit: inherit)
.with(reserved: reserved)
+ .with(deprecation: deprecation)
.metadata(metadata)
@nodes ||= {}
diff --git a/lib/gitlab/config/entry/factory.rb b/lib/gitlab/config/entry/factory.rb
index f76c98f7cbf..61f2071b62f 100644
--- a/lib/gitlab/config/entry/factory.rb
+++ b/lib/gitlab/config/entry/factory.rb
@@ -32,6 +32,10 @@ module Gitlab
self
end
+ def deprecation
+ @attributes[:deprecation]
+ end
+
def description
@attributes[:description]
end
@@ -84,6 +88,7 @@ module Gitlab
node.parent = @attributes[:parent]
node.default = @attributes[:default]
node.description = @attributes[:description]
+ node.deprecation = @attributes[:deprecation]
end
end
end
diff --git a/lib/gitlab/config/entry/node.rb b/lib/gitlab/config/entry/node.rb
index 32912cb1046..6ce7046262b 100644
--- a/lib/gitlab/config/entry/node.rb
+++ b/lib/gitlab/config/entry/node.rb
@@ -10,7 +10,7 @@ module Gitlab
InvalidError = Class.new(StandardError)
attr_reader :config, :metadata
- attr_accessor :key, :parent, :default, :description
+ attr_accessor :key, :parent, :default, :description, :deprecation
def initialize(config, **metadata)
@config = config
@@ -128,6 +128,24 @@ module Gitlab
private
attr_reader :entries
+
+ def log_and_warn_deprecated_entry(entry)
+ user = metadata[:user]
+ project = metadata[:project]
+
+ if project && user
+ Gitlab::AppJsonLogger.info(event: 'ci_used_deprecated_keyword',
+ entry: entry.key.to_s,
+ user_id: user.id,
+ project_id: project.id)
+ end
+
+ deprecation = entry.deprecation
+ add_warning(
+ "`#{entry.key}` is deprecated in " \
+ "#{deprecation[:deprecated]} and will be removed in #{deprecation[:removed]}."
+ )
+ end
end
end
end