diff options
-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"] |