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>2019-11-01 15:06:26 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-01 15:06:26 +0300
commitdeed6022efe0149d88c57ef1df736c83465643f9 (patch)
tree4cf4c7c1ce765e83547129607b6bd3881c0fad6b /lib/gitlab/config
parentf7a13c56bf0ed7ff9591bf4cbf9e50487255c4bc (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/config')
-rw-r--r--lib/gitlab/config/entry/configurable.rb29
-rw-r--r--lib/gitlab/config/entry/node.rb4
-rw-r--r--lib/gitlab/config/entry/simplifiable.rb11
-rw-r--r--lib/gitlab/config/entry/validatable.rb21
4 files changed, 23 insertions, 42 deletions
diff --git a/lib/gitlab/config/entry/configurable.rb b/lib/gitlab/config/entry/configurable.rb
index bda84dc2cff..b7ec4b7c4f8 100644
--- a/lib/gitlab/config/entry/configurable.rb
+++ b/lib/gitlab/config/entry/configurable.rb
@@ -29,24 +29,22 @@ module Gitlab
def compose!(deps = nil)
return unless valid?
- super do
- self.class.nodes.each do |key, factory|
- # If we override the config type validation
- # we can end with different config types like String
- next unless config.is_a?(Hash)
+ self.class.nodes.each do |key, factory|
+ # If we override the config type validation
+ # we can end with different config types like String
+ next unless config.is_a?(Hash)
- factory
- .value(config[key])
- .with(key: key, parent: self)
+ factory
+ .value(config[key])
+ .with(key: key, parent: self)
- entries[key] = factory.create!
- end
+ entries[key] = factory.create!
+ end
- yield if block_given?
+ yield if block_given?
- entries.each_value do |entry|
- entry.compose!(deps)
- end
+ entries.each_value do |entry|
+ entry.compose!(deps)
end
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -69,13 +67,12 @@ 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)
factory = ::Gitlab::Config::Entry::Factory.new(entry)
.with(description: description)
.with(default: default)
.with(inherit: inherit)
.with(reserved: reserved)
- .metadata(metadata)
(@nodes ||= {}).merge!(key.to_sym => factory)
end
diff --git a/lib/gitlab/config/entry/node.rb b/lib/gitlab/config/entry/node.rb
index 84d3409ed91..e014f15fbd8 100644
--- a/lib/gitlab/config/entry/node.rb
+++ b/lib/gitlab/config/entry/node.rb
@@ -112,10 +112,6 @@ module Gitlab
@aspects ||= []
end
- def self.with_aspect(blk)
- self.aspects.append(blk)
- end
-
private
attr_reader :entries
diff --git a/lib/gitlab/config/entry/simplifiable.rb b/lib/gitlab/config/entry/simplifiable.rb
index 315f1947e2c..d58aba07d15 100644
--- a/lib/gitlab/config/entry/simplifiable.rb
+++ b/lib/gitlab/config/entry/simplifiable.rb
@@ -4,11 +4,11 @@ module Gitlab
module Config
module Entry
class Simplifiable < SimpleDelegator
- EntryStrategy = Struct.new(:name, :klass, :condition)
+ EntryStrategy = Struct.new(:name, :condition)
attr_reader :subject
- def initialize(config, **metadata, &blk)
+ def initialize(config, **metadata)
unless self.class.const_defined?(:UnknownStrategy)
raise ArgumentError, 'UndefinedStrategy not available!'
end
@@ -19,13 +19,14 @@ module Gitlab
entry = self.class.entry_class(strategy)
- @subject = entry.new(config, metadata, &blk)
+ @subject = entry.new(config, metadata)
+ yield(@subject) if block_given?
super(@subject)
end
def self.strategy(name, **opts)
- EntryStrategy.new(name, opts.dig(:class), opts.fetch(:if)).tap do |strategy|
+ EntryStrategy.new(name, opts.fetch(:if)).tap do |strategy|
strategies.append(strategy)
end
end
@@ -36,7 +37,7 @@ module Gitlab
def self.entry_class(strategy)
if strategy.present?
- strategy.klass || self.const_get(strategy.name, false)
+ self.const_get(strategy.name, false)
else
self::UnknownStrategy
end
diff --git a/lib/gitlab/config/entry/validatable.rb b/lib/gitlab/config/entry/validatable.rb
index 45b852dc2e0..1c88c68c11c 100644
--- a/lib/gitlab/config/entry/validatable.rb
+++ b/lib/gitlab/config/entry/validatable.rb
@@ -7,27 +7,14 @@ module Gitlab
extend ActiveSupport::Concern
def self.included(node)
- node.with_aspect -> do
- validate(:new)
+ node.aspects.append -> do
+ @validator = self.class.validator.new(self)
+ @validator.validate(:new)
end
end
- def validator
- @validator ||= self.class.validator.new(self)
- end
-
- def validate(context = nil)
- validator.validate(context)
- end
-
- def compose!(deps = nil, &blk)
- super(deps, &blk)
-
- validate(:composed)
- end
-
def errors
- validator.messages + descendants.flat_map(&:errors)
+ @validator.messages + descendants.flat_map(&:errors) # rubocop:disable Gitlab/ModuleWithInstanceVariables
end
class_methods do