Welcome to mirror list, hosted at ThFree Co, Russian Federation.

mapper.rb « external « config « ci « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fcd65b2f2d7e33bd4d7d8429a7a8b1d826080be9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# frozen_string_literal: true

module Gitlab
  module Ci
    class Config
      module External
        class Mapper
          include Gitlab::Utils::StrongMemoize

          Error = Class.new(StandardError)
          AmbigiousSpecificationError = Class.new(Error)
          TooManyIncludesError = Class.new(Error)
          TooMuchDataInPipelineTreeError = Class.new(Error)
          InvalidTypeError = Class.new(Error)

          def initialize(values, context)
            @locations = Array.wrap(values.fetch(:include, [])).compact
            @context = context
          end

          def process
            return [] if @locations.empty?

            context.logger.instrument(:config_mapper_process) do
              process_without_instrumentation
            end
          end

          private

          attr_reader :context

          delegate :expandset, :logger, to: :context

          def process_without_instrumentation
            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
        end
      end
    end
  end
end