diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-06-14 11:28:20 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-06-14 11:28:20 +0200 |
commit | 30e946ce8a9272b3de1a64498965933804b7bb6d (patch) | |
tree | 6f5114eb1d8c1272652b3fe9af06e7bdfdddefad /lib | |
parent | 59eeec3ff87ce175e34ac96e86c9690c5290502b (diff) | |
download | gitlab-ce-30e946ce8a9272b3de1a64498965933804b7bb6d.tar.gz |
Validate ci config entry value before processing nodesrefactor/ci-config-add-global-entry
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/ci/config/node/configurable.rb | 14 | ||||
-rw-r--r-- | lib/gitlab/ci/config/node/entry.rb | 5 |
2 files changed, 11 insertions, 8 deletions
diff --git a/lib/gitlab/ci/config/node/configurable.rb b/lib/gitlab/ci/config/node/configurable.rb index 7587c8c34c9..d60f87f3f94 100644 --- a/lib/gitlab/ci/config/node/configurable.rb +++ b/lib/gitlab/ci/config/node/configurable.rb @@ -16,20 +16,18 @@ module Gitlab module Configurable extend ActiveSupport::Concern - def initialize(*) - super - - unless @value.is_a?(Hash) - @errors << 'should be a configuration entry with hash value' - end - end - def allowed_nodes self.class.allowed_nodes || {} end private + def prevalidate! + unless @value.is_a?(Hash) + @errors << 'should be a configuration entry with hash value' + end + end + def create_node(key, factory) factory.with(value: @value[key]) factory.nullify! unless @value.has_key?(key) diff --git a/lib/gitlab/ci/config/node/entry.rb b/lib/gitlab/ci/config/node/entry.rb index 507312e0c09..52758a962f3 100644 --- a/lib/gitlab/ci/config/node/entry.rb +++ b/lib/gitlab/ci/config/node/entry.rb @@ -14,6 +14,8 @@ module Gitlab @value = value @nodes = {} @errors = [] + + prevalidate! end def process! @@ -56,6 +58,9 @@ module Gitlab private + def prevalidate! + end + def compose! allowed_nodes.each do |key, essence| @nodes[key] = create_node(key, essence) |