diff options
author | Robert Speicher <robert@gitlab.com> | 2018-09-06 03:05:20 +0300 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2018-09-06 03:05:20 +0300 |
commit | ab22dae917cc38d6d9573fca472d09950fac8d08 (patch) | |
tree | f5380f2e973dc1ec179bfc33d6110b7d26f33a0a /lib/api | |
parent | e7cb8a4195ce0b22dc7173aff0e56b9e322a8882 (diff) | |
parent | d65e31ab72b09c539fac4bac391d1f6ff3152c58 (diff) |
Merge branch 'ce-5306-more-custom-templates' into 'master'
CE backport of changes that introduce custom instance-level templates to EE
See merge request gitlab-org/gitlab-ce!21530
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/templates.rb | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/api/templates.rb b/lib/api/templates.rb index 927baaea652..7bf0e0f5934 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 @@ -36,7 +33,7 @@ module API popular = declared(params)[:popular] popular = to_boolean(popular) if popular.present? - templates = LicenseTemplateFinder.new(popular: popular).execute + templates = TemplateFinder.build(:licenses, popular: popular).execute present paginate(::Kaminari.paginate_array(templates)), with: ::API::Entities::License end @@ -49,7 +46,7 @@ module API requires :name, type: String, desc: 'The name of the template' end get "templates/licenses/:name", requirements: { name: /[\w\.-]+/ } do - templates = LicenseTemplateFinder.new.execute + templates = TemplateFinder.build(:licenses).execute template = templates.find { |template| template.key == params[:name] } not_found!('License') unless template.present? @@ -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.build(template_type, name: declared(params)[:name]) + new_template = finder.execute render_response(template_type, new_template) end |