Commit b95c60a0 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Do not process Ci config node when node is a leaf

parent 940763e0
...@@ -16,6 +16,8 @@ module Gitlab ...@@ -16,6 +16,8 @@ module Gitlab
end end
def process! def process!
return if leaf?
keys.each_pair do |key, entry| keys.each_pair do |key, entry|
next unless @value.include?(key) next unless @value.include?(key)
@nodes[key] = entry.new(@value[key], @config, self) @nodes[key] = entry.new(@value[key], @config, self)
...@@ -29,12 +31,16 @@ module Gitlab ...@@ -29,12 +31,16 @@ module Gitlab
@errors + nodes.map(&:errors).flatten @errors + nodes.map(&:errors).flatten
end end
def nodes
@nodes.values
end
def valid? def valid?
errors.none? errors.none?
end end
def nodes def leaf?
@nodes.values keys.none?
end end
def keys def keys
......
...@@ -31,6 +31,12 @@ describe Gitlab::Ci::Config::Node::Global do ...@@ -31,6 +31,12 @@ describe Gitlab::Ci::Config::Node::Global do
.to be_an_instance_of Gitlab::Ci::Config::Node::BeforeScript .to be_an_instance_of Gitlab::Ci::Config::Node::BeforeScript
end end
end end
describe '#leaf?' do
it 'is not leaf' do
expect(global).not_to be_leaf
end
end
end end
context 'when hash is not valid' do context 'when hash is not valid' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment