From 7a4ae082c216d68092f140ed1f5cca40ffb1a09e Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Mon, 10 Dec 2007 17:59:51 -0600 Subject: 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. --- lib/puppet/util/settings.rb | 7 ++++++- spec/unit/util/settings.rb | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) 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"] -- cgit