diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-06-06 10:43:11 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-06-06 10:43:11 +0200 |
commit | 8048dcc8e693d713a94a7b9361672692f4e5932f (patch) | |
tree | a1e950928ef04785fd67b940be2746ce9ed49a9c /lib | |
parent | 7f2f683eeb2c3b443f519e2e83dbb3d789a00cf8 (diff) | |
download | gitlab-ce-8048dcc8e693d713a94a7b9361672692f4e5932f.tar.gz |
Implement CI configuration nodes tree processing
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/ci/config/node/before_script.rb | 7 | ||||
-rw-r--r-- | lib/gitlab/ci/config/node/entry.rb | 22 | ||||
-rw-r--r-- | lib/gitlab/ci/config/node/global.rb | 3 |
3 files changed, 28 insertions, 4 deletions
diff --git a/lib/gitlab/ci/config/node/before_script.rb b/lib/gitlab/ci/config/node/before_script.rb index bf73c01efbc..88ebd6bb304 100644 --- a/lib/gitlab/ci/config/node/before_script.rb +++ b/lib/gitlab/ci/config/node/before_script.rb @@ -3,8 +3,11 @@ module Gitlab class Config module Node class BeforeScript < Entry - def leaf? - true + def keys + {} + end + + def validate! end end end diff --git a/lib/gitlab/ci/config/node/entry.rb b/lib/gitlab/ci/config/node/entry.rb index eb1b52a3e5d..6336535bc03 100644 --- a/lib/gitlab/ci/config/node/entry.rb +++ b/lib/gitlab/ci/config/node/entry.rb @@ -3,14 +3,32 @@ module Gitlab class Config module Node class Entry + attr_reader :hash, :config, :parent, :nodes, :errors + def initialize(hash, config, parent = nil) @hash = hash @config = config @parent = parent + @nodes = {} + @errors = [] + end + + def process! + keys.each_pair do |key, entry| + next unless hash.include?(key) + @nodes[key] = entry.new(hash[key], config, self) + end + + @nodes.values.each(&:process!) + @nodes.values.each(&:validate!) + end + + def keys + raise NotImplementedError end - def allowed_keys - [] + def validate! + raise NotImplementedError end end end diff --git a/lib/gitlab/ci/config/node/global.rb b/lib/gitlab/ci/config/node/global.rb index b3dd6df0a44..81a9d0667be 100644 --- a/lib/gitlab/ci/config/node/global.rb +++ b/lib/gitlab/ci/config/node/global.rb @@ -3,6 +3,9 @@ module Gitlab class Config module Node class Global < Entry + def keys + { before_script: BeforeScript } + end end end end |