From e57436f1056cceb8ecdfadfa618911c5595c72e2 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Mon, 5 May 2008 21:14:46 -0500 Subject: The Settings class now clears the 'used' sections when a value is changed. This makes is so that if you, for instance, reset the vardir, then the next time an initialization call is made, we reuse any previously used sections, thus (hopefully) correctly creating any newly needed directories. This is mostly helpful during testing. --- lib/puppet/util/settings.rb | 4 +++- spec/unit/util/settings.rb | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb index 65668f919..09bba5b59 100644 --- a/lib/puppet/util/settings.rb +++ b/lib/puppet/util/settings.rb @@ -39,6 +39,8 @@ class Puppet::Util::Settings end @values[:memory][param] = value @cache.clear + + clearused end return value @@ -574,7 +576,7 @@ Generated on #{Time.now}. catalog = bucket.to_catalog rescue => detail puts detail.backtrace if Puppet[:trace] - Puppet.err "Could not create resources for managing Puppet's files and directories: %s" % detail + Puppet.err "Could not create resources for managing Puppet's files and directories in sections %s: %s" % [sections.inspect, detail] # We need some way to get rid of any resources created during the catalog creation # but not cleaned up. diff --git a/spec/unit/util/settings.rb b/spec/unit/util/settings.rb index 441a3f4ef..ca533ef9a 100755 --- a/spec/unit/util/settings.rb +++ b/spec/unit/util/settings.rb @@ -93,6 +93,11 @@ describe Puppet::Util::Settings, " when setting values" do @settings[:myval].should == "yay" end + it "should clear the list of used sections" do + @settings.expects(:clearused) + @settings[:myval] = "yay" + end + it "should call passed blocks when values are set" do values = [] @settings.setdefaults(:section, :hooker => {:default => "yay", :desc => "boo", :hook => lambda { |v| values << v }}) -- cgit