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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2018-08-28 16:14:39 +0300
committerNick Thomas <nick@gitlab.com>2018-09-05 17:10:39 +0300
commit03c733849c1fad9885b0b947e60744633b7f5bd6 (patch)
tree013bd8a1a0470f053178e51f22f517907c58bb8b /app/finders
parentdb28db414c8ab3d253294e430cd99d14499fad2e (diff)
Convert global templates to vendored templates via a ::TemplateFinder
Diffstat (limited to 'app/finders')
-rw-r--r--app/finders/template_finder.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/app/finders/template_finder.rb b/app/finders/template_finder.rb
new file mode 100644
index 00000000000..a9e6fc9edb3
--- /dev/null
+++ b/app/finders/template_finder.rb
@@ -0,0 +1,27 @@
+class TemplateFinder
+ VENDORED_TEMPLATES = {
+ dockerfiles: ::Gitlab::Template::DockerfileTemplate,
+ gitignores: ::Gitlab::Template::GitignoreTemplate,
+ gitlab_ci_ymls: ::Gitlab::Template::GitlabCiYmlTemplate
+ }.freeze
+
+ attr_reader :type, :params
+
+ attr_reader :vendored_templates
+ private :vendored_templates
+
+ def initialize(type, params = {})
+ @type = type
+ @params = params
+
+ @vendored_templates = VENDORED_TEMPLATES.fetch(type)
+ end
+
+ def execute
+ if params[:name]
+ vendored_templates.find(params[:name])
+ else
+ vendored_templates.all
+ end
+ end
+end