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