diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-24 15:09:00 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-24 15:09:00 +0300 |
commit | ae78b85a25cb0c19c3d6a2e4e6c7ca91ed50787d (patch) | |
tree | c53ad0fcdab26725814f1dc5267f6a04ebe4cf73 /lib/gitlab/config | |
parent | 38149afcf95e7669a7a99828c579d185b70c04dc (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/config')
-rw-r--r-- | lib/gitlab/config/entry/configurable.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/gitlab/config/entry/configurable.rb b/lib/gitlab/config/entry/configurable.rb index e7d441bb21c..75e15cd8cb1 100644 --- a/lib/gitlab/config/entry/configurable.rb +++ b/lib/gitlab/config/entry/configurable.rb @@ -75,6 +75,8 @@ module Gitlab # rubocop: disable CodeReuse/ActiveRecord def entry(key, entry, description: nil, default: nil, inherit: nil, reserved: nil, metadata: {}) + raise ArgumentError, "Entry #{key} already defined" if @nodes.to_h[key.to_sym] + factory = ::Gitlab::Config::Entry::Factory.new(entry) .with(description: description) .with(default: default) @@ -86,8 +88,16 @@ module Gitlab end # rubocop: enable CodeReuse/ActiveRecord - def helpers(*nodes) + def helpers(*nodes, dynamic: false) nodes.each do |symbol| + if method_defined?("#{symbol}_defined?") || method_defined?("#{symbol}_value") + raise ArgumentError, "Method #{symbol}_defined? or #{symbol}_value already defined" + end + + unless @nodes.to_h[symbol] + raise ArgumentError, "Entry for #{symbol} is undefined" unless dynamic + end + define_method("#{symbol}_defined?") do entries[symbol]&.specified? end |