diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-06-27 14:12:47 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-06-27 14:16:57 +0200 |
commit | c019585cb83b1852451184663085e6f0e0d12024 (patch) | |
tree | 969d3dff5f728f78b4827b2c037435ed12b16f2e /lib | |
parent | 56e88b8c28282976be258ba53a9f82662cc74703 (diff) | |
download | gitlab-ce-c019585cb83b1852451184663085e6f0e0d12024.tar.gz |
Validate interface only with CI node validator
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/ci/config/node/cache.rb | 29 | ||||
-rw-r--r-- | lib/gitlab/ci/config/node/validator.rb | 3 |
2 files changed, 17 insertions, 15 deletions
diff --git a/lib/gitlab/ci/config/node/cache.rb b/lib/gitlab/ci/config/node/cache.rb index c6508e59c4b..251d7aa9097 100644 --- a/lib/gitlab/ci/config/node/cache.rb +++ b/lib/gitlab/ci/config/node/cache.rb @@ -8,30 +8,33 @@ module Gitlab class Cache < Entry include Configurable + node :key, Key, + description: 'Cache key used to define a cache affinity.' + + node :untracked, Boolean, + description: 'Cache all untracked files.' + + node :paths, Paths, + description: 'Specify which paths should be cached across builds.' + validations do - validate :allowed_keys + validate :keys def unknown_keys - return [] unless @node.config.is_a?(Hash) - - @node.config.keys - @node.class.nodes.keys + return [] unless config.is_a?(Hash) + config.keys - allowed_keys end - def allowed_keys + def keys if unknown_keys.any? errors.add(:config, "contains unknown keys #{unknown_keys}") end end end - node :key, Node::Key, - description: 'Cache key used to define a cache affinity.' - - node :untracked, Boolean, - description: 'Cache all untracked files.' - - node :paths, Paths, - description: 'Specify which paths should be cached across builds.' + def allowed_keys + self.class.nodes.keys + end end end end diff --git a/lib/gitlab/ci/config/node/validator.rb b/lib/gitlab/ci/config/node/validator.rb index 5f62d68710d..18e795d2c42 100644 --- a/lib/gitlab/ci/config/node/validator.rb +++ b/lib/gitlab/ci/config/node/validator.rb @@ -8,12 +8,11 @@ module Gitlab def initialize(node) super(node) - @node = node end def messages errors.full_messages.map do |error| - "#{@node.key} #{error}".humanize + "#{key} #{error}".humanize end end |