2018-12-13 13:39:08 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
class Config
|
|
|
|
module External
|
|
|
|
class Mapper
|
2019-02-15 15:39:39 +05:30
|
|
|
include Gitlab::Utils::StrongMemoize
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
Error = Class.new(StandardError)
|
|
|
|
AmbigiousSpecificationError = Class.new(Error)
|
|
|
|
TooManyIncludesError = Class.new(Error)
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
def initialize(values, context)
|
2023-03-04 22:38:38 +05:30
|
|
|
@locations = Array.wrap(values.fetch(:include, [])).compact
|
2019-12-21 20:55:43 +05:30
|
|
|
@context = context
|
2018-12-13 13:39:08 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def process
|
2023-03-04 22:38:38 +05:30
|
|
|
return [] if @locations.empty?
|
|
|
|
|
|
|
|
context.logger.instrument(:config_mapper_process) do
|
2023-03-17 16:20:25 +05:30
|
|
|
process_without_instrumentation
|
2022-01-26 12:08:38 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
attr_reader :context
|
2022-01-26 12:08:38 +05:30
|
|
|
|
|
|
|
delegate :expandset, :logger, to: :context
|
|
|
|
|
|
|
|
def process_without_instrumentation
|
2023-03-04 22:38:38 +05:30
|
|
|
locations = Normalizer.new(context).process(@locations)
|
|
|
|
locations = Filter.new(context).process(locations)
|
|
|
|
locations = LocationExpander.new(context).process(locations)
|
|
|
|
locations = VariablesExpander.new(context).process(locations)
|
|
|
|
|
|
|
|
files = Matcher.new(context).process(locations)
|
|
|
|
Verifier.new(context).process(files)
|
|
|
|
|
|
|
|
files
|
|
|
|
end
|
2018-12-13 13:39:08 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|