From 912d34a5016a15084f59b5568e329875e377bdcb Mon Sep 17 00:00:00 2001 From: "Z.J. van de Weg" Date: Wed, 28 Sep 2016 22:14:33 +0200 Subject: Ground work for Kubernetes config files dropdown Fixes, at least partially #21486. TODO: - [ ] Frontend - [ ] Create a project containing all the configuration files - [ ] Add tests [ci skip] --- lib/api/templates.rb | 5 +++-- lib/gitlab/template/kubernetes_config_template.rb | 25 +++++++++++++++++++++++ lib/tasks/gitlab/update_templates.rake | 5 ++++- 3 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 lib/gitlab/template/kubernetes_config_template.rb diff --git a/lib/api/templates.rb b/lib/api/templates.rb index b9e718147e1..a64730b0715 100644 --- a/lib/api/templates.rb +++ b/lib/api/templates.rb @@ -1,8 +1,9 @@ module API class Templates < Grape::API GLOBAL_TEMPLATE_TYPES = { - gitignores: Gitlab::Template::GitignoreTemplate, - gitlab_ci_ymls: Gitlab::Template::GitlabCiYmlTemplate + gitignores: Gitlab::Template::GitignoreTemplate, + gitlab_ci_ymls: Gitlab::Template::GitlabCiYmlTemplate, + kubernetes_config: Gitlab::Template::KubernetesConfigTemplate }.freeze helpers do diff --git a/lib/gitlab/template/kubernetes_config_template.rb b/lib/gitlab/template/kubernetes_config_template.rb new file mode 100644 index 00000000000..a70550f31f4 --- /dev/null +++ b/lib/gitlab/template/kubernetes_config_template.rb @@ -0,0 +1,25 @@ +module Gitlab + module Template + class KubernetesConfigTemplate < BaseTemplate + class << self + def extension + '_pod.yaml' + end + + def categories + { + "Default" => '' + } + end + + def base_dir + Rails.root.join('vendor/kubernetes') + end + + def finder(project = nil) + Gitlab::Template::Finders::GlobalTemplateFinder.new(self.base_dir, self.extension, self.categories) + end + end + end + end +end diff --git a/lib/tasks/gitlab/update_templates.rake b/lib/tasks/gitlab/update_templates.rake index 4f76dad7286..7459cc82b19 100644 --- a/lib/tasks/gitlab/update_templates.rake +++ b/lib/tasks/gitlab/update_templates.rake @@ -45,7 +45,10 @@ namespace :gitlab do Template.new( "https://gitlab.com/gitlab-org/gitlab-ci-yml.git", /(\.{1,2}|LICENSE|Pages|\.gitlab-ci.yml)\z/ - ) + ), + Template.new( + "https://gitlab.com/gitlab-org/to-be-determined.git", + /(\.{1,2}|_pod.yaml)\z/ ] def vendor_directory -- cgit v1.2.1