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