Commit da2e373a authored by Matija Čupić's avatar Matija Čupić

Simplify Need differentiation

Simplified Need differentiation by adding #type to be used instead
of #bridge and #pipeline.
parent b00c3f71
......@@ -25,12 +25,8 @@ module EE
validates :pipeline, type: String, presence: true
end
def bridge?
true
end
def pipeline?
false
def type
:bridge
end
end
......
......@@ -14,16 +14,12 @@ module Gitlab
validates :config, presence: true
end
def bridge?
false
end
def pipeline?
true
def type
:pipeline
end
def value
@config.to_s
{ name: @config }
end
end
......
......@@ -16,7 +16,7 @@ module Gitlab
def compose!(deps = nil)
super(deps) do
[].tap { |array| array.push(@config) }.flatten.each_with_index do |need, index|
[@config].flatten.each_with_index do |need, index|
@entries[index] = ::Gitlab::Config::Entry::Factory.new(Entry::Need)
.value(need)
.with(key: "need", parent: self, description: "need definition.") # rubocop:disable CodeReuse/ActiveRecord
......@@ -30,21 +30,10 @@ module Gitlab
end
def value
{}.tap do |result_hash|
result_hash[:bridge] = bridge_values.first if bridge_values.any?
result_hash[:pipeline] = pipeline_values if pipeline_values.any?
@entries.values.group_by(&:type).transform_values do |values|
values.map(&:value)
end
end
private
def bridge_values
@entries.values.select(&:bridge?).map(&:value)
end
def pipeline_values
@entries.values.select(&:pipeline?).map(&:value)
end
end
end
end
......
......@@ -40,7 +40,7 @@ module Gitlab
environment: job[:environment_name],
coverage_regex: job[:coverage],
yaml_variables: yaml_variables(name),
needs_attributes: job.dig(:needs, :pipeline)&.map { |need| { name: need } },
needs_attributes: job.dig(:needs, :pipeline),
interruptible: job[:interruptible],
rules: job[:rules],
options: {
......
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