Skip to content

Commit

Permalink
(FIXUP) Simplify PDK::Generate::Module.default_template_url
Browse files Browse the repository at this point in the history
  • Loading branch information
scotje committed Aug 15, 2017
1 parent a3918a1 commit 4e86cff
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions lib/pdk/generators/module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ module PDK
module Generate
class Module
def self.default_template_url
PDK::Util.package_install? ? vendored_template_url : 'https://github.com/puppetlabs/pdk-module-template'
if !PDK.answers['template-url'].nil?
PDK.answers['template-url']
elsif PDK::Util.package_install?
'file://' + File.join(PDK::Util.package_cachedir, 'pdk-module-template.git')
else
'https://github.com/puppetlabs/pdk-module-template'
end
end

def self.invoke(opts = {})
Expand Down Expand Up @@ -44,7 +50,7 @@ def self.invoke(opts = {})

prepare_module_directory(temp_target_dir)

template_url = opts.fetch(:'template-url', PDK.answers['template-url'] || default_template_url)
template_url = opts.fetch(:'template-url', default_template_url)

PDK::Module::TemplateDir.new(template_url, metadata.data) do |templates|
templates.render do |file_path, file_content|
Expand Down Expand Up @@ -243,14 +249,6 @@ def self.module_interview(metadata, opts = {})
'license' => answers['license'],
)
end

class << self
private

def vendored_template_url
'file://' + File.join(PDK::Util.package_cachedir, 'pdk-module-template.git')
end
end
end
end
end

0 comments on commit 4e86cff

Please sign in to comment.