diff options
Diffstat (limited to 'lib/api/templates.rb')
-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 |