Commit eaf211c2 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Expose compose method in the ci config entry nodes

parent 700078e8
......@@ -14,7 +14,7 @@ module Gitlab
@config = Loader.new(config).load!
@global = Node::Global.new(@config)
@global.process!
@global.compose!
end
def valid?
......
......@@ -23,9 +23,9 @@ module Gitlab
end
end
private
def compose!(deps)
return unless valid?
def compose!(_deps)
self.class.nodes.each do |key, factory|
factory
.value(@config[key])
......@@ -33,6 +33,12 @@ module Gitlab
@entries[key] = factory.create!
end
yield if block_given?
@entries.each_value do |entry|
entry.compose!(deps)
end
end
class_methods do
......
......@@ -20,14 +20,16 @@ module Gitlab
@validator.validate(:new)
end
# Temporary method
#
def process!(deps = nil)
return unless valid?
compose!(deps)
descendants.each do |entry|
entry.process!(deps)
end
def compose!(deps = nil)
return unless valid?
yield if block_given?
end
def leaf?
......@@ -76,11 +78,6 @@ module Gitlab
def self.validator
Validator
end
private
def compose!(_deps)
end
end
end
end
......
......@@ -36,18 +36,14 @@ module Gitlab
helpers :before_script, :image, :services, :after_script,
:variables, :stages, :types, :cache, :jobs
def process!(_deps = nil)
super(self)
end
private
def compose!(_deps)
super
def compose!(_deps = nil)
super(self) do
compose_jobs!
compose_deprecated_entries!
end
end
private
def compose_jobs!
factory = Node::Factory.new(Node::Jobs)
......
......@@ -82,6 +82,16 @@ module Gitlab
:cache, :image, :services, :only, :except, :variables,
:artifacts
def compose!(deps)
super do
if type_defined? && !stage_defined?
@entries[:stage] = @entries[:type]
end
@entries.delete(:type)
end
end
def name
@metadata[:name]
end
......@@ -106,16 +116,6 @@ module Gitlab
artifacts: artifacts,
after_script: after_script }
end
def compose!(_deps)
super
if type_defined? && !stage_defined?
@entries[:stage] = @entries[:type]
end
@entries.delete(:type)
end
end
end
end
......
......@@ -26,9 +26,8 @@ module Gitlab
name.to_s.start_with?('.')
end
private
def compose!(_deps)
def compose!(deps = nil)
super do
@config.each do |name, config|
node = hidden?(name) ? Node::HiddenJob : Node::Job
......@@ -40,6 +39,11 @@ module Gitlab
@entries[name] = factory.create!
end
@entries.each_value do |entry|
entry.compose!(deps)
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