summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/external/mapper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/ci/external/mapper.rb')
-rw-r--r--lib/gitlab/ci/external/mapper.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/gitlab/ci/external/mapper.rb b/lib/gitlab/ci/external/mapper.rb
new file mode 100644
index 00000000000..f2e5ec972df
--- /dev/null
+++ b/lib/gitlab/ci/external/mapper.rb
@@ -0,0 +1,31 @@
+module Gitlab
+ module Ci
+ module External
+ class Mapper
+ def initialize(values, project, branch_name)
+ @paths = Array(values.fetch(:include, []))
+ @project = project
+ @branch_name = branch_name
+ end
+
+ def process
+ paths.map { |path| build_external_file(path) }
+ end
+
+ private
+
+ attr_reader :paths, :project, :branch_name
+
+ def build_external_file(path)
+ remote_file = Gitlab::Ci::External::File::Remote.new(path)
+
+ if remote_file.valid?
+ remote_file
+ else
+ ::Gitlab::Ci::External::File::Local.new(path, project, branch_name)
+ end
+ end
+ end
+ end
+ end
+end