Validate ci config entry value before processing nodes
This commit is contained in:
parent
59eeec3ff8
commit
30e946ce8a
2 changed files with 11 additions and 8 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue