Verified Commit a02fe0d5 authored by Matija Čupić's avatar Matija Čupić
Browse files

Remove support for symbol job name in need

Removes the support for specifying a job in symbol format in need.
parent e37777e4
......@@ -5,17 +5,18 @@ module Gitlab
class Config
module Entry
class Need < ::Gitlab::Config::Entry::Simplifiable
strategy :Pipeline, if: -> (config) { config.is_a?(String) || config.is_a?(Symbol) }
strategy :Pipeline, if: -> (config) { config.is_a?(String) }
 
class Pipeline < ::Gitlab::Config::Entry::Node
include ::Gitlab::Config::Entry::Validatable
 
validations do
validates :config, presence: true
validates :config, type: String
end
 
def self.matching?(config)
config.is_a?(String) || config.is_a?(Symbol)
config.is_a?(String)
end
 
def type
......
......@@ -13,6 +13,12 @@ module Gitlab
validations do
validates :config, presence: true
 
validate do
unless config.is_a?(Hash) || config.is_a?(Array)
errors.add(:config, 'can only be a hash or an array')
end
end
validate do
[config].flatten.each do |need|
if Needs.find_type(need).nil?
......
......@@ -163,7 +163,7 @@ module Gitlab
 
stage_index = @stages.index(job[:stage])
 
job[:needs][:pipeline].each do |need|
job.dig(:needs, :pipeline).each do |need|
need_job_name = need[:name]
 
raise ValidationError, "#{name} job: undefined need: #{need_job_name}" unless @jobs[need_job_name.to_sym]
......
......@@ -19,20 +19,6 @@ describe ::Gitlab::Ci::Config::Entry::Need do
end
end
 
context 'when job is specified as symbol' do
let(:config) { :job_name }
describe '#valid?' do
it { is_expected.to be_valid }
end
describe '#value' do
it 'returns job needs configuration' do
expect(need.value).to eq(name: :job_name)
end
end
end
context 'when need is empty' do
let(:config) { '' }
 
......
......@@ -18,6 +18,21 @@ describe ::Gitlab::Ci::Config::Entry::Needs do
end
end
 
context 'when config value has wrong type' do
let(:config) { 123 }
describe '#valid?' do
it { is_expected.not_to be_valid }
end
describe '#errors' do
it 'returns error about incorrect type' do
expect(needs.errors)
.to include('needs config can only be a hash or an array')
end
end
end
context 'when wrong needs type is used' do
let(:config) { [123] }
 
......
......@@ -1305,12 +1305,6 @@ module Gitlab
end
end
 
context 'needs two builds defined as symbols' do
let(:needs) { [:build1, :build2] }
it { expect { subject }.not_to raise_error }
end
context 'undefined need' do
let(:needs) { ['undefined'] }
 
......
Supports Markdown
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