Commit df25c196 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Use Ci config validation helpers only where needed

parent 6bd67f52
......@@ -2,7 +2,7 @@ module Ci
class GitlabCiYamlProcessor
class ValidationError < StandardError; end
include Gitlab::Ci::Config::ValidationHelpers
include Gitlab::Ci::Config::Node::ValidationHelpers
DEFAULT_STAGES = %w(build test deploy)
DEFAULT_STAGE = 'test'
......
......@@ -3,6 +3,8 @@ module Gitlab
class Config
module Node
class BeforeScript < Entry
include ValidationHelpers
def keys
{}
end
......
......@@ -3,8 +3,6 @@ module Gitlab
class Config
module Node
class Entry
include Config::ValidationHelpers
attr_reader :value, :nodes, :parent
def initialize(value, root = nil, parent = nil)
......
module Gitlab
module Ci
class Config
module Node
module ValidationHelpers
private
def validate_array_of_strings(values)
values.is_a?(Array) && values.all? { |value| validate_string(value) }
end
def validate_variables(variables)
variables.is_a?(Hash) &&
variables.all? { |key, value| validate_string(key) && validate_string(value) }
end
def validate_string(value)
value.is_a?(String) || value.is_a?(Symbol)
end
def validate_boolean(value)
value.in?([true, false])
end
end
end
end
end
end
module Gitlab
module Ci
class Config
module ValidationHelpers
private
def validate_array_of_strings(values)
values.is_a?(Array) && values.all? { |value| validate_string(value) }
end
def validate_variables(variables)
variables.is_a?(Hash) &&
variables.all? { |key, value| validate_string(key) && validate_string(value) }
end
def validate_string(value)
value.is_a?(String) || value.is_a?(Symbol)
end
def validate_boolean(value)
value.in?([true, false])
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment