Commit cd72189f authored by Matija Čupić's avatar Matija Čupić

Import external files in Gitlab CI config

CE mirror of a10b777f8cb1902bba3964a4cbad2b1dd6bce785
parent 5f33690e
...@@ -464,7 +464,7 @@ module Ci ...@@ -464,7 +464,7 @@ module Ci
return @config_processor if defined?(@config_processor) return @config_processor if defined?(@config_processor)
@config_processor ||= begin @config_processor ||= begin
Gitlab::Ci::YamlProcessor.new(ci_yaml_file) Gitlab::Ci::YamlProcessor.new(ci_yaml_file, project)
rescue Gitlab::Ci::YamlProcessor::ValidationError => e rescue Gitlab::Ci::YamlProcessor::ValidationError => e
self.yaml_errors = e.message self.yaml_errors = e.message
nil nil
......
...@@ -6,12 +6,17 @@ module Gitlab ...@@ -6,12 +6,17 @@ module Gitlab
class Config class Config
ConfigError = Class.new(StandardError) ConfigError = Class.new(StandardError)
def initialize(config, opts = {}) def initialize(config, project = nil, opts = {})
initial_config = Config::Extendable initial_config = Config::Extendable
.new(build_config(config, opts)) .new(build_config(config, opts))
.to_hash .to_hash
if project.present?
processor = ::Gitlab::Ci::ExternalFiles::Processor.new(initial_config) processor = ::Gitlab::Ci::ExternalFiles::Processor.new(initial_config)
@config = processor.perform @config = processor.perform
else
@config = initial_config
end
@global = Entry::Global.new(@config) @global = Entry::Global.new(@config)
@global.compose! @global.compose!
......
...@@ -7,8 +7,8 @@ module Gitlab ...@@ -7,8 +7,8 @@ module Gitlab
attr_reader :cache, :stages, :jobs attr_reader :cache, :stages, :jobs
def initialize(config, opts = {}) def initialize(config, project = nil, opts = {})
@ci_config = Gitlab::Ci::Config.new(config, opts) @ci_config = Gitlab::Ci::Config.new(config, project, opts)
@config = @ci_config.to_hash @config = @ci_config.to_hash
unless @ci_config.valid? unless @ci_config.valid?
......
...@@ -3,8 +3,9 @@ require 'fast_spec_helper' ...@@ -3,8 +3,9 @@ require 'fast_spec_helper'
require_dependency 'active_model' require_dependency 'active_model'
describe Gitlab::Ci::Config do describe Gitlab::Ci::Config do
let(:project) { create(:project, :repository) }
let(:config) do let(:config) do
described_class.new(yml) described_class.new(yml, project)
end end
context 'when config is valid' do context 'when config is valid' do
...@@ -125,7 +126,6 @@ describe Gitlab::Ci::Config do ...@@ -125,7 +126,6 @@ describe Gitlab::Ci::Config do
end end
end end
context "when yml has valid 'includes' defined" do context "when yml has valid 'includes' defined" do
let(:yml) do let(:yml) do
<<-EOS <<-EOS
......
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