diff options
author | Luke Kanies <luke@madstop.com> | 2007-12-10 17:59:51 -0600 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2007-12-10 17:59:51 -0600 |
commit | 7a4ae082c216d68092f140ed1f5cca40ffb1a09e (patch) | |
tree | 18404a765506d34f959f2e4880939b157eb735a6 | |
parent | 3790ce1c6463e0d44ae0151fdc24000b9d5ede27 (diff) | |
download | puppet-7a4ae082c216d68092f140ed1f5cca40ffb1a09e.tar.gz puppet-7a4ae082c216d68092f140ed1f5cca40ffb1a09e.tar.xz puppet-7a4ae082c216d68092f140ed1f5cca40ffb1a09e.zip |
Fixing the rest of #948. My previous work was sufficient,
except that I was not passing the interpolated value in
to the hook, which meant the libdir was set to something
like $vardir/lib.
-rw-r--r-- | lib/puppet/util/settings.rb | 7 | ||||
-rwxr-xr-x | spec/unit/util/settings.rb | 14 |
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb index 4a802d424..7b446e736 100644 --- a/lib/puppet/util/settings.rb +++ b/lib/puppet/util/settings.rb @@ -308,7 +308,12 @@ class Puppet::Util::Settings settings_with_hooks.each do |setting| each_source(env) do |source| if value = @values[source][setting.name] - setting.handle(value) + # We still have to use value() to retrieve the value, since + # we want the fully interpolated value, not $vardir/lib or whatever. + # This results in extra work, but so few of the settings + # will have associated hooks that it ends up being less work this + # way overall. + setting.handle(self.value(setting.name, env)) break end end diff --git a/spec/unit/util/settings.rb b/spec/unit/util/settings.rb index ab93d87de..5a0333798 100755 --- a/spec/unit/util/settings.rb +++ b/spec/unit/util/settings.rb @@ -382,6 +382,20 @@ describe Puppet::Util::Settings, " when parsing its configuration" do values.should == ["other"] end + it "should pass the interpolated value to the hook when one is available" do + values = [] + @settings.setdefaults :section, :base => {:default => "yay", :desc => "a", :hook => proc { |v| values << v }} + @settings.setdefaults :section, :mysetting => {:default => "defval", :desc => "a", :hook => proc { |v| values << v }} + + text = "[main] + mysetting = $base/setval + " + file = "/some/file" + @settings.expects(:read_file).with(file).returns(text) + @settings.parse(file) + values.should == ["yay/setval"] + end + it "should allow empty values" do @settings.setdefaults :section, :myarg => ["myfile", "a"] |