diff options
author | Luke Kanies <luke@madstop.com> | 2009-08-31 23:38:26 -0700 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-09-01 21:05:05 +1000 |
commit | 3342b73b6acf5e7c492fa352b16ba9aba3c60da8 (patch) | |
tree | 2f6f45b77f61519fa5616c1df8632c9428a35471 | |
parent | d397f8d1d1092067f7ca52449ce9af63f02f44e1 (diff) | |
download | puppet-3342b73b6acf5e7c492fa352b16ba9aba3c60da8.tar.gz puppet-3342b73b6acf5e7c492fa352b16ba9aba3c60da8.tar.xz puppet-3342b73b6acf5e7c492fa352b16ba9aba3c60da8.zip |
Fixing #2577 - clarifying and demoting the deprecation notice
It's now just notice instead of a warning, and it clarifies
that 0.24 clients can't be present.
Signed-off-by: Luke Kanies <luke@madstop.com>
-rw-r--r-- | lib/puppet/file_serving/configuration.rb | 2 | ||||
-rw-r--r-- | lib/puppet/util/warnings.rb | 26 | ||||
-rwxr-xr-x | spec/unit/file_serving/configuration.rb | 2 | ||||
-rwxr-xr-x | spec/unit/util/warnings.rb | 38 |
4 files changed, 40 insertions, 28 deletions
diff --git a/lib/puppet/file_serving/configuration.rb b/lib/puppet/file_serving/configuration.rb index a247f53dd..ac54a7a8a 100644 --- a/lib/puppet/file_serving/configuration.rb +++ b/lib/puppet/file_serving/configuration.rb @@ -41,7 +41,7 @@ class Puppet::FileServing::Configuration end if environment.module(mount_name) - Puppet::Util::Warnings.warnonce "DEPRECATION NOTICE: Found module '%s' without using the 'modules' mount; please prefix path with 'modules/'" % mount_name + Puppet::Util::Warnings.notice_once "DEPRECATION NOTICE: Files found in modules without specifying 'modules' in file path will be deprecated in the next major release. Please fix module '%s' when no 0.24.x clients are present" % mount_name return mounts["modules"] end diff --git a/lib/puppet/util/warnings.rb b/lib/puppet/util/warnings.rb index 97c96b74c..a63d91359 100644 --- a/lib/puppet/util/warnings.rb +++ b/lib/puppet/util/warnings.rb @@ -2,20 +2,28 @@ module Puppet::Util::Warnings module_function + def notice_once(msg) + Puppet::Util::Warnings.maybe_log(msg, self.class) { Puppet.notice msg } + end + + def warnonce(msg) - $stampwarnings ||= {} - $stampwarnings[self.class] ||= [] - unless $stampwarnings[self.class].include? msg - Puppet.warning msg - $stampwarnings[self.class] << msg - end + Puppet::Util::Warnings.maybe_log(msg, self.class) { Puppet.warning msg } + end + def clear_warnings() + @stampwarnings = {} return nil end - def clear_warnings() - $stampwarnings = {} + protected + + def self.maybe_log(message, klass) + @stampwarnings ||= {} + @stampwarnings[klass] ||= [] + return nil if @stampwarnings[klass].include? message + yield + @stampwarnings[klass] << message return nil end end - diff --git a/spec/unit/file_serving/configuration.rb b/spec/unit/file_serving/configuration.rb index c2f386f14..f6acfad39 100755 --- a/spec/unit/file_serving/configuration.rb +++ b/spec/unit/file_serving/configuration.rb @@ -140,7 +140,7 @@ describe Puppet::FileServing::Configuration do mount = mock 'mount' config.stubs(:mounts).returns("modules" => mount) - Puppet::Util::Warnings.expects(:warnonce) + Puppet::Util::Warnings.expects(:notice_once) config.find_mount("foo", env).should equal(mount) end diff --git a/spec/unit/util/warnings.rb b/spec/unit/util/warnings.rb index 46bd1cc2d..15785cf58 100755 --- a/spec/unit/util/warnings.rb +++ b/spec/unit/util/warnings.rb @@ -2,31 +2,35 @@ require File.dirname(__FILE__) + '/../../spec_helper' -describe Puppet::Util::Warnings, " when registering a warning message" do +describe Puppet::Util::Warnings do before(:all) do @msg1 = "booness" @msg2 = "more booness" end - it "should always return nil" do - Puppet::Util::Warnings.warnonce(@msg1).should be(nil) - end + {:notice => "notice_once", :warning => "warnonce"}.each do |log, method| + describe "when registring '%s' messages" % log do + it "should always return nil" do + Puppet::Util::Warnings.send(method, @msg1).should be(nil) + end - it "should issue a warning" do - Puppet.expects(:warning).with(@msg1) - Puppet::Util::Warnings.warnonce(@msg1) - end + it "should issue a warning" do + Puppet.expects(log).with(@msg1) + Puppet::Util::Warnings.send(method, @msg1) + end - it "should issue a warning exactly once per unique message" do - Puppet.expects(:warning).with(@msg1).once - Puppet::Util::Warnings.warnonce(@msg1) - Puppet::Util::Warnings.warnonce(@msg1) - end + it "should issue a warning exactly once per unique message" do + Puppet.expects(log).with(@msg1).once + Puppet::Util::Warnings.send(method, @msg1) + Puppet::Util::Warnings.send(method, @msg1) + end - it "should issue multiple warnings for multiple unique messages" do - Puppet.expects(:warning).times(2) - Puppet::Util::Warnings.warnonce(@msg1) - Puppet::Util::Warnings.warnonce(@msg2) + it "should issue multiple warnings for multiple unique messages" do + Puppet.expects(log).times(2) + Puppet::Util::Warnings.send(method, @msg1) + Puppet::Util::Warnings.send(method, @msg2) + end + end end after(:each) do |