Commit 7316400f authored by Matija Čupić's avatar Matija Čupić

Simplify needs value transformation

parent a02fe0d5
...@@ -88,7 +88,7 @@ describe EE::Gitlab::Ci::Config::Entry::Bridge do ...@@ -88,7 +88,7 @@ describe EE::Gitlab::Ci::Config::Entry::Bridge do
describe '#value' do describe '#value' do
it 'is returns a bridge job configuration' do it 'is returns a bridge job configuration' do
expect(subject.value).to eq(name: :my_bridge, expect(subject.value).to eq(name: :my_bridge,
needs: { bridge: { pipeline: 'some/project' } }, needs: { bridge: [{ pipeline: 'some/project' }] },
ignore: false, ignore: false,
stage: 'test', stage: 'test',
only: { refs: %w[branches tags] }) only: { refs: %w[branches tags] })
......
...@@ -52,7 +52,7 @@ describe ::Gitlab::Ci::Config::Entry::Needs do ...@@ -52,7 +52,7 @@ describe ::Gitlab::Ci::Config::Entry::Needs do
describe '#value' do describe '#value' do
it 'returns key value' do it 'returns key value' do
expect(needs.value).to eq(pipeline: [{ name: 'first_job_name' }], bridge: { pipeline: 'some/project' }) expect(needs.value).to eq(pipeline: [{ name: 'first_job_name' }], bridge: [{ pipeline: 'some/project' }])
end end
end end
......
...@@ -58,13 +58,9 @@ module Gitlab ...@@ -58,13 +58,9 @@ module Gitlab
end end
def value def value
values = @entries.values.group_by(&:type).transform_values do |values| @entries.values.group_by(&:type).transform_values do |values|
values.map(&:value) values.map(&:value)
end end
values.tap do |values_hash|
values_hash[:bridge] = values_hash[:bridge].first if values_hash[:bridge]
end
end end
end end
end end
......
...@@ -59,7 +59,7 @@ module Gitlab ...@@ -59,7 +59,7 @@ module Gitlab
instance: job[:instance], instance: job[:instance],
start_in: job[:start_in], start_in: job[:start_in],
trigger: job[:trigger], trigger: job[:trigger],
bridge_needs: job.dig(:needs, :bridge) bridge_needs: job.dig(:needs, :bridge)&.first
}.compact }.compact }.compact }.compact
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