summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/config/node/configurable.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/ci/config/node/configurable.rb')
-rw-r--r--lib/gitlab/ci/config/node/configurable.rb20
1 files changed, 8 insertions, 12 deletions
diff --git a/lib/gitlab/ci/config/node/configurable.rb b/lib/gitlab/ci/config/node/configurable.rb
index d60f87f3f94..374ff71d0f5 100644
--- a/lib/gitlab/ci/config/node/configurable.rb
+++ b/lib/gitlab/ci/config/node/configurable.rb
@@ -15,27 +15,24 @@ module Gitlab
#
module Configurable
extend ActiveSupport::Concern
+ include Validatable
- def allowed_nodes
- self.class.allowed_nodes || {}
+ included do
+ validations do
+ validates :config, hash: true
+ end
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)
+ factory.with(value: @config[key], key: key)
+ factory.nullify! unless @config.has_key?(key)
factory.create!
end
class_methods do
- def allowed_nodes
+ def nodes
Hash[@allowed_nodes.map { |key, factory| [key, factory.dup] }]
end
@@ -47,7 +44,6 @@ module Gitlab
define_method(symbol) do
raise Entry::InvalidError unless valid?
-
@nodes[symbol].try(:value)
end