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

Simplify the GitlabCiYamlProcessor#initial_parsing method

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