Commit 0ccf6295 authored by Tomasz Maczukin's avatar Tomasz Maczukin

Simplify the GitlabCiYamlProcessor#initial_parsing method

parent e1b3ce54
......@@ -61,28 +61,23 @@ module Ci
@stages = @config[:stages] || @config[:types]
@variables = @config[:variables] || {}
@cache = @config[:cache]
@config.except!(*ALLOWED_YAML_KEYS)
@jobs = {}
@config.except!(*ALLOWED_YAML_KEYS)
@config.each do |name, param|
raise ValidationError, "Unknown parameter: #{name}" unless is_a_job?(name, param)
end
unless @config.values.any?{|job| job.is_a?(Hash)}
raise ValidationError, "Please define at least one job"
add_job(name, param)
end
@jobs = {}
@config.each do |key, job|
next if key.to_s.start_with?('.')
stage = job[:stage] || job[:type] || DEFAULT_STAGE
@jobs[key] = { stage: stage }.merge(job)
end
raise ValidationError, "Please define at least one job" if @jobs.none?
end
def is_a_job?(name, value)
return true if value.is_a?(Hash) && value.has_key?(:script)
return true if name.to_s.start_with?('.')
false
def add_job(name, job)
return if name.to_s.start_with?('.')
raise ValidationError, "Unknown parameter: #{name}" unless job.is_a?(Hash) && job.has_key?(:script)
stage = job[:stage] || job[:type] || DEFAULT_STAGE
@jobs[name] = { stage: stage }.merge(job)
end
def build_job(name, job)
......
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