diff options
author | Nick Thomas <nick@gitlab.com> | 2018-10-03 00:00:38 +0100 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-10-05 11:34:43 +0100 |
commit | 25bd49e4f57fe15f9d61dc9376a5b7dc35b30f64 (patch) | |
tree | faef4e9d73e9845413462013c868eace19a11abf /app/finders/template_finder.rb | |
parent | ae014e189773f7299c12c1050334b3e8fe7b15d8 (diff) | |
download | gitlab-ce-25bd49e4f57fe15f9d61dc9376a5b7dc35b30f64.tar.gz |
Backport project template API to CE
Diffstat (limited to 'app/finders/template_finder.rb')
-rw-r--r-- | app/finders/template_finder.rb | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/app/finders/template_finder.rb b/app/finders/template_finder.rb index c92ee9ca9ac..3e483716064 100644 --- a/app/finders/template_finder.rb +++ b/app/finders/template_finder.rb @@ -1,29 +1,32 @@ # frozen_string_literal: true class TemplateFinder - VENDORED_TEMPLATES = { + include Gitlab::Utils::StrongMemoize + + VENDORED_TEMPLATES = HashWithIndifferentAccess.new( dockerfiles: ::Gitlab::Template::DockerfileTemplate, gitignores: ::Gitlab::Template::GitignoreTemplate, gitlab_ci_ymls: ::Gitlab::Template::GitlabCiYmlTemplate - }.freeze + ).freeze class << self - def build(type, params = {}) - if type == :licenses - LicenseTemplateFinder.new(params) # rubocop: disable CodeReuse/Finder + def build(type, project, params = {}) + if type.to_s == 'licenses' + LicenseTemplateFinder.new(project, params) # rubocop: disable CodeReuse/Finder else - new(type, params) + new(type, project, params) end end end - attr_reader :type, :params + attr_reader :type, :project, :params attr_reader :vendored_templates private :vendored_templates - def initialize(type, params = {}) + def initialize(type, project, params = {}) @type = type + @project = project @params = params @vendored_templates = VENDORED_TEMPLATES.fetch(type) |