summaryrefslogtreecommitdiff
path: root/lib/gitlab/config
diff options
context:
space:
mode:
authorKamil TrzciƄski <ayufan@ayufan.eu>2019-06-18 10:36:07 +0000
committerGrzegorz Bizon <grzegorz@gitlab.com>2019-06-18 10:36:07 +0000
commit505d71ec88e04f649251b3848a094a9e5ab0f8d5 (patch)
tree9e823a5fa17771ec01b3e0cb33b6283d217dd12e /lib/gitlab/config
parentc167cc58d3efe2bf1d8f9ccb1a58d7819fef1901 (diff)
downloadgitlab-ce-505d71ec88e04f649251b3848a094a9e5ab0f8d5.tar.gz
Introduce default: for gitlab-ci.yml
This moves all existing `image/services/before_script/variables` into `default:`. This allows us to easily add a default and top-level entries. `default`: is keep backward compatible: to be considered to be job if `default:script:` is specified. This behavior should be removed. All existing `image/services/before_script/variables` are properly handled in root context.
Diffstat (limited to 'lib/gitlab/config')
-rw-r--r--lib/gitlab/config/entry/configurable.rb14
-rw-r--r--lib/gitlab/config/entry/factory.rb12
2 files changed, 23 insertions, 3 deletions
diff --git a/lib/gitlab/config/entry/configurable.rb b/lib/gitlab/config/entry/configurable.rb
index 6667a5d3d33..b7ec4b7c4f8 100644
--- a/lib/gitlab/config/entry/configurable.rb
+++ b/lib/gitlab/config/entry/configurable.rb
@@ -58,13 +58,21 @@ module Gitlab
Hash[(@nodes || {}).map { |key, factory| [key, factory.dup] }]
end
+ def reserved_node_names
+ self.nodes.select do |_, node|
+ node.reserved?
+ end.keys
+ end
+
private
# rubocop: disable CodeReuse/ActiveRecord
- def entry(key, entry, metadata)
+ def entry(key, entry, description: nil, default: nil, inherit: nil, reserved: nil)
factory = ::Gitlab::Config::Entry::Factory.new(entry)
- .with(description: metadata[:description])
- .with(default: metadata[:default])
+ .with(description: description)
+ .with(default: default)
+ .with(inherit: inherit)
+ .with(reserved: reserved)
(@nodes ||= {}).merge!(key.to_sym => factory)
end
diff --git a/lib/gitlab/config/entry/factory.rb b/lib/gitlab/config/entry/factory.rb
index 3c06b1e0d24..8f1f4a81bb5 100644
--- a/lib/gitlab/config/entry/factory.rb
+++ b/lib/gitlab/config/entry/factory.rb
@@ -30,6 +30,18 @@ module Gitlab
self
end
+ def description
+ @attributes[:description]
+ end
+
+ def inheritable?
+ @attributes[:inherit]
+ end
+
+ def reserved?
+ @attributes[:reserved]
+ end
+
def create!
raise InvalidFactory unless defined?(@value)