Commit 1f320edb authored by Grzegorz Bizon's avatar Grzegorz Bizon

Minor refactorings in new CI configuration classes

parent 29b96d92
...@@ -91,6 +91,11 @@ module Ci ...@@ -91,6 +91,11 @@ module Ci
{ {
stage_idx: @stages.index(job[:stage]), stage_idx: @stages.index(job[:stage]),
stage: job[:stage], stage: job[:stage],
##
# Refactoring note:
# - before script behaves differently than after script
# - after script returns an array of commands
# - before script should be a concatenated command
commands: [job[:before_script] || @before_script, job[:script]].flatten.compact.join("\n"), commands: [job[:before_script] || @before_script, job[:script]].flatten.compact.join("\n"),
tag_list: job[:tags] || [], tag_list: job[:tags] || [],
name: name, name: name,
......
...@@ -52,7 +52,7 @@ module Gitlab ...@@ -52,7 +52,7 @@ module Gitlab
factory = Node::Factory.new(entry_class) factory = Node::Factory.new(entry_class)
.with(description: metadata[:description]) .with(description: metadata[:description])
(@nodes ||= {}).merge!(symbol => factory) (@nodes ||= {}).merge!(symbol.to_sym => factory)
end end
end end
end end
......
...@@ -44,8 +44,7 @@ module Gitlab ...@@ -44,8 +44,7 @@ module Gitlab
end end
def errors def errors
@validator.full_errors + @validator.messages + nodes.flat_map(&:errors)
nodes.map(&:errors).flatten
end end
def value def value
......
...@@ -11,7 +11,7 @@ module Gitlab ...@@ -11,7 +11,7 @@ module Gitlab
@node = node @node = node
end end
def full_errors def messages
errors.full_messages.map do |error| errors.full_messages.map do |error|
"#{@node.key} #{error}".humanize "#{@node.key} #{error}".humanize
end end
......
...@@ -19,7 +19,7 @@ describe Gitlab::Ci::Config::Node::Validator do ...@@ -19,7 +19,7 @@ describe Gitlab::Ci::Config::Node::Validator do
it 'returns no errors' do it 'returns no errors' do
validator_instance.validate validator_instance.validate
expect(validator_instance.full_errors).to be_empty expect(validator_instance.messages).to be_empty
end end
end end
...@@ -36,7 +36,7 @@ describe Gitlab::Ci::Config::Node::Validator do ...@@ -36,7 +36,7 @@ describe Gitlab::Ci::Config::Node::Validator do
it 'returns errors' do it 'returns errors' do
validator_instance.validate validator_instance.validate
expect(validator_instance.full_errors).not_to be_empty expect(validator_instance.messages).not_to be_empty
end end
end end
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