[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35

Markus Roberts Markus at reality.com
Wed Jul 14 10:36:18 UTC 2010


The following commit has been merged in the upstream branch:
commit 3304068fe96df86c3616f3f441595811d71162b0
Author: Jesse Wolfe <jes5199 at gmail.com>
Date:   Thu Jul 1 15:15:14 2010 -0700

    maint: :mutable_defaults to improve spec consistency
    
    Added a Puppet::Util::Settings layer called :mutable_defaults to emulate
    the interaction between Puppet::Application and defaults.rb that was
    getting thwarted by rspec.

diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb
index ac2cc10..35d6024 100644
--- a/lib/puppet/application.rb
+++ b/lib/puppet/application.rb
@@ -280,6 +280,19 @@ class Application
 
         $puppet_application_mode = @run_mode
         $puppet_application_name = name
+        
+        if Puppet.respond_to? :settings
+            # This is to reduce the amount of confusion in rspec
+            # because it might have loaded defaults.rb before the globals were set
+            # and thus have the wrong defaults for the current application
+            Puppet.settings.set_value(:confdir, Puppet.run_mode.conf_dir, :mutable_defaults)
+            Puppet.settings.set_value(:vardir, Puppet.run_mode.var_dir, :mutable_defaults)
+            Puppet.settings.set_value(:name, Puppet.application_name.to_s, :mutable_defaults)
+            Puppet.settings.set_value(:logdir, Puppet.run_mode.logopts, :mutable_defaults)
+            Puppet.settings.set_value(:rundir, Puppet.run_mode.run_dir, :mutable_defaults)
+            Puppet.settings.set_value(:mode, Puppet.run_mode.name.to_s, :mutable_defaults)
+        end
+
         require 'puppet'
     end
 
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb
index ac82975..ed06231 100644
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@ -6,7 +6,8 @@ module Puppet
         it defaults to being in ``~``."],
         :vardir => [Puppet.run_mode.var_dir, "Where Puppet stores dynamic and growing data.  The default for this parameter is calculated specially, like `confdir`_."],
         :name => [Puppet.application_name.to_s, "The name of the application, if we are running as one.  The
-            default is essentially $0 without the path or ``.rb``."]
+            default is essentially $0 without the path or ``.rb``."],
+        :mode => [Puppet.run_mode.name.to_s, "The effective 'run mode' of the application: master, agent, or user."]
     )
 
     setdefaults(:main, :logdir => Puppet.run_mode.logopts)
diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb
index 3e2020c..d1e1448 100644
--- a/lib/puppet/util/settings.rb
+++ b/lib/puppet/util/settings.rb
@@ -443,9 +443,9 @@ class Puppet::Util::Settings
     # The order in which to search for values.
     def searchpath(environment = nil)
         if environment
-            [:cli, :memory, environment, :run_mode, :main]
+            [:cli, :memory, environment, :run_mode, :main, :mutable_defaults]
         else
-            [:cli, :memory, :run_mode, :main]
+            [:cli, :memory, :run_mode, :main, :mutable_defaults]
         end
     end
 
@@ -490,7 +490,7 @@ class Puppet::Util::Settings
         if setting.respond_to?(:handle) and not options[:dont_trigger_handles]
             setting.handle(value)
         end
-        if ReadOnly.include? param
+        if ReadOnly.include? param and type != :mutable_defaults
             raise ArgumentError,
                 "You're attempting to set configuration parameter $#{param}, which is read-only."
         end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list