diff options
author | Nick Thomas <nick@gitlab.com> | 2018-08-28 16:14:39 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-09-05 17:10:39 +0300 |
commit | 03c733849c1fad9885b0b947e60744633b7f5bd6 (patch) | |
tree | 013bd8a1a0470f053178e51f22f517907c58bb8b /lib/api | |
parent | db28db414c8ab3d253294e430cd99d14499fad2e (diff) |
Convert global templates to vendored templates via a ::TemplateFinder
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/templates.rb | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/api/templates.rb b/lib/api/templates.rb index 927baaea652..5d817d36032 100644 --- a/lib/api/templates.rb +++ b/lib/api/templates.rb @@ -4,15 +4,12 @@ module API GLOBAL_TEMPLATE_TYPES = { gitignores: { - klass: Gitlab::Template::GitignoreTemplate, gitlab_version: 8.8 }, gitlab_ci_ymls: { - klass: Gitlab::Template::GitlabCiYmlTemplate, gitlab_version: 8.9 }, dockerfiles: { - klass: Gitlab::Template::DockerfileTemplate, gitlab_version: 8.15 } }.freeze @@ -63,7 +60,6 @@ module API end GLOBAL_TEMPLATE_TYPES.each do |template_type, properties| - klass = properties[:klass] gitlab_version = properties[:gitlab_version] desc 'Get the list of the available template' do @@ -74,7 +70,7 @@ module API use :pagination end get "templates/#{template_type}" do - templates = ::Kaminari.paginate_array(klass.all) + templates = ::Kaminari.paginate_array(TemplateFinder.new(template_type).execute) present paginate(templates), with: Entities::TemplatesList end @@ -86,7 +82,8 @@ module API requires :name, type: String, desc: 'The name of the template' end get "templates/#{template_type}/:name" do - new_template = klass.find(declared(params)[:name]) + finder = TemplateFinder.new(template_type, name: declared(params)[:name]) + new_template = finder.execute render_response(template_type, new_template) end |