Skip to content
Snippets Groups Projects
Commit 30e946ce authored by Grzegorz Bizon's avatar Grzegorz Bizon
Browse files

Validate ci config entry value before processing nodes

parent 59eeec3f
No related branches found
No related tags found
1 merge request!4482Add global entry with before script to new CI config
Pipeline #
Loading
@@ -16,20 +16,18 @@ module Gitlab
Loading
@@ -16,20 +16,18 @@ module Gitlab
module Configurable module Configurable
extend ActiveSupport::Concern 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 def allowed_nodes
self.class.allowed_nodes || {} self.class.allowed_nodes || {}
end end
   
private private
   
def prevalidate!
unless @value.is_a?(Hash)
@errors << 'should be a configuration entry with hash value'
end
end
def create_node(key, factory) def create_node(key, factory)
factory.with(value: @value[key]) factory.with(value: @value[key])
factory.nullify! unless @value.has_key?(key) factory.nullify! unless @value.has_key?(key)
Loading
Loading
Loading
@@ -14,6 +14,8 @@ module Gitlab
Loading
@@ -14,6 +14,8 @@ module Gitlab
@value = value @value = value
@nodes = {} @nodes = {}
@errors = [] @errors = []
prevalidate!
end end
   
def process! def process!
Loading
@@ -56,6 +58,9 @@ module Gitlab
Loading
@@ -56,6 +58,9 @@ module Gitlab
   
private private
   
def prevalidate!
end
def compose! def compose!
allowed_nodes.each do |key, essence| allowed_nodes.each do |key, essence|
@nodes[key] = create_node(key, essence) @nodes[key] = create_node(key, essence)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment