Fixed #1012 - templates in the templatedir are preferred to module templates.

This commit is contained in:
Luke Kanies 2008-06-16 23:59:18 -05:00
Родитель 543181272d
Коммит 2380fcd4d1
3 изменённых файлов: 18 добавлений и 3 удалений

Просмотреть файл

@ -1,4 +1,6 @@
0.24.?
Fixed #1012 - templates in the templatedir are preferred to module templates.
Fixed #1360 - allowdupe works on groups again.
Fixed #1369 - the init service provider now supports HP-UX.

Просмотреть файл

@ -63,6 +63,10 @@ class Puppet::Module
return template
end
# If we can find the template in :templatedir, we return that.
td_file = File.join(Puppet.settings.value(:templatedir, environment), template)
return td_file if File.exists?(td_file)
path, file = split_path(template)
# Because templates don't have an assumed template name, like manifests do,
@ -76,7 +80,7 @@ class Puppet::Module
if mod
return mod.template(file)
else
return File.join(Puppet.settings.value(:templatedir, environment), template)
return td_file # Return this anyway, since we're going to fail.
end
end

Просмотреть файл

@ -80,6 +80,14 @@ describe Puppet::Module, " when searching for templates" do
File.stubs(:directory?).returns(true)
Puppet::Module.find_template("mymod/mytemplate").should == "/one/mymod/templates/mytemplate"
end
it "should return the file in the templatedir if it exists" do
Puppet.settings.expects(:value).with(:templatedir, nil).returns("/my/templates")
Puppet[:modulepath] = "/one:/two"
File.stubs(:directory?).returns(true)
File.stubs(:exists?).returns(true)
Puppet::Module.find_template("mymod/mytemplate").should == "/my/templates/mymod/mytemplate"
end
it "should use the main templatedir if no module is found" do
Puppet.settings.expects(:value).with(:templatedir, nil).returns("/my/templates")
@ -100,9 +108,10 @@ describe Puppet::Module, " when searching for templates" do
end
it "should use the node environment if specified" do
Puppet.settings.expects(:value).with(:modulepath, "myenv").returns("/my/templates")
Puppet.settings.stubs(:value).returns.returns("/my/directory")
Puppet.settings.expects(:value).with(:modulepath, "myenv").returns("/my/modules")
File.stubs(:directory?).returns(true)
Puppet::Module.find_template("mymod/envtemplate", "myenv").should == "/my/templates/mymod/templates/envtemplate"
Puppet::Module.find_template("mymod/envtemplate", "myenv").should == "/my/modules/mymod/templates/envtemplate"
end
after { Puppet.settings.clear }