diff options
author | Paul Nasrat <pnasrat@googlemail.com> | 2008-09-16 10:24:19 +0100 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2008-09-20 19:43:56 +1000 |
commit | 7f8abbd388ee3898c8505ca3bb884b75d8db2087 (patch) | |
tree | e0c8f950d1f9bf9364a85a27a12a1a5c4cefd8c5 /lib | |
parent | 09057346dd7207e36c81bae479d1343fb7cc8d0a (diff) | |
download | puppet-7f8abbd388ee3898c8505ca3bb884b75d8db2087.tar.gz puppet-7f8abbd388ee3898c8505ca3bb884b75d8db2087.tar.xz puppet-7f8abbd388ee3898c8505ca3bb884b75d8db2087.zip |
Bug #1550 - Rework to avoid regressing rspec tests, add new rspec tests for templatedir as a path
Signed-off-by: Paul Nasrat <pnasrat@googlemail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/defaults.rb | 3 | ||||
-rw-r--r-- | lib/puppet/module.rb | 24 |
2 files changed, 17 insertions, 10 deletions
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index 87ccd62f6..a2900fd43 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -664,7 +664,8 @@ module Puppet setdefaults(:parser, :lexical => [false, "Whether to use lexical scoping (vs. dynamic)."], :templatedir => ["$vardir/templates", - "Where Puppet looks for template files." + "Where Puppet looks for template files. Can be a list of colon-seperated + directories." ] ) diff --git a/lib/puppet/module.rb b/lib/puppet/module.rb index 4bdfab092..b34f2f8b0 100644 --- a/lib/puppet/module.rb +++ b/lib/puppet/module.rb @@ -72,28 +72,33 @@ class Puppet::Module return template end + template_paths = templatepath(environment) + default_template_path = File::join(template_paths.first, template) + # If we can find the template in :templatedir, we return that. - td_file = templatepath(environment).collect { |path| + td_file = template_paths.collect { |path| File::join(path, template) }.find { |f| File.exists?(f) } return td_file unless td_file == nil + td_file = find_template_for_module(template, environment) + td_file ||= default_template_path + end + + def self.find_template_for_module(template, environment = nil) path, file = split_path(template) # Because templates don't have an assumed template name, like manifests do, # we treat templates with no name as being templates in the main template # directory. - if file.nil? - mod = nil - else + if not file.nil? mod = find(path, environment) + if mod + return mod.template(file) + end end - if mod - return mod.template(file) - else - return td_file # Return this anyway, since we're going to fail. - end + nil end # Return a list of manifests (as absolute filenames) that match +pat+ @@ -156,4 +161,5 @@ class Puppet::Module end private :initialize + private_class_method :find_template_for_module end |