Commit e8f995ef authored by Grzegorz Bizon's avatar Grzegorz Bizon

Pass root Ci config entry to each subsequent entry

parent 69a3755c
...@@ -13,7 +13,7 @@ module Gitlab ...@@ -13,7 +13,7 @@ module Gitlab
end end
@config = loader.load @config = loader.load
@global = Node::Global.new(@config, self) @global = Node::Global.new(@config)
@global.process! @global.process!
end end
......
...@@ -7,14 +7,14 @@ module Gitlab ...@@ -7,14 +7,14 @@ module Gitlab
attr_reader :value, :nodes, :parent attr_reader :value, :nodes, :parent
def initialize(value, config, parent = nil) def initialize(value, root = nil, parent = nil)
@value = value @value = value
@config = config @root = root
@parent = parent @parent = parent
@nodes, @errors = [], [] @nodes, @errors = [], []
keys.each_key do |key| keys.each_key do |key|
instance_variable_set("@#{key}", Null.new(nil, config, self)) instance_variable_set("@#{key}", Null.new(nil, root, self))
end end
end end
...@@ -24,7 +24,7 @@ module Gitlab ...@@ -24,7 +24,7 @@ module Gitlab
keys.each do |key, entry_class| keys.each do |key, entry_class|
next unless @value.has_key?(key) next unless @value.has_key?(key)
entry = entry_class.new(@value[key], @config, self) entry = entry_class.new(@value[key], @root, self)
instance_variable_set("@#{key}", entry) instance_variable_set("@#{key}", entry)
@nodes.append(entry) @nodes.append(entry)
end end
...@@ -42,7 +42,7 @@ module Gitlab ...@@ -42,7 +42,7 @@ module Gitlab
end end
def leaf? def leaf?
keys.none? keys.none? # TODO || !@value.is_a?(Hash)
end end
def keys def keys
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::Ci::Config::Node::BeforeScript do describe Gitlab::Ci::Config::Node::BeforeScript do
let(:entry) { described_class.new(value, config) } let(:entry) { described_class.new(value, double)}
let(:config) { double('config') }
describe '#validate!' do describe '#validate!' do
before { entry.validate! } before { entry.validate! }
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::Ci::Config::Node::Global do describe Gitlab::Ci::Config::Node::Global do
let(:global) { described_class.new(hash, config) } let(:global) { described_class.new(hash) }
let(:config) { double('Config') }
describe '#keys' do describe '#keys' do
it 'can contain global config keys' do it 'can contain global config keys' 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