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

mapper.rb « external « ci « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 58bd6a19acf982c91021c7697b2e70bff0e56e00 (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
# frozen_string_literal: true

module Gitlab
  module Ci
    module External
      class Mapper
        def initialize(values, project, sha)
          @locations = Array(values.fetch(:include, []))
          @project = project
          @sha = sha
        end

        def process
          locations.map { |location| build_external_file(location) }
        end

        private

        attr_reader :locations, :project, :sha

        def build_external_file(location)
          if ::Gitlab::UrlSanitizer.valid?(location)
            Gitlab::Ci::External::File::Remote.new(location)
          else
            options = { project: project, sha: sha }
            Gitlab::Ci::External::File::Local.new(location, options)
          end
        end
      end
    end
  end
end