diff options
author | Nick Thomas <nick@gitlab.com> | 2018-08-28 15:14:39 +0200 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-09-05 15:10:39 +0100 |
commit | 03c733849c1fad9885b0b947e60744633b7f5bd6 (patch) | |
tree | 013bd8a1a0470f053178e51f22f517907c58bb8b /app/finders | |
parent | db28db414c8ab3d253294e430cd99d14499fad2e (diff) | |
download | gitlab-ce-03c733849c1fad9885b0b947e60744633b7f5bd6.tar.gz |
Convert global templates to vendored templates via a ::TemplateFinder
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/template_finder.rb | 27 |
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 |