summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2010-07-01 15:15:14 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-02 12:31:52 -0700
commit3304068fe96df86c3616f3f441595811d71162b0 (patch)
tree1ad6941251cc417cd023b16fca0a86703ec296e9 /lib
parent08b49c6f52452f6aec7d5345bce6c6e126454380 (diff)
downloadpuppet-3304068fe96df86c3616f3f441595811d71162b0.tar.gz
puppet-3304068fe96df86c3616f3f441595811d71162b0.tar.xz
puppet-3304068fe96df86c3616f3f441595811d71162b0.zip
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/application.rb13
-rw-r--r--lib/puppet/defaults.rb3
-rw-r--r--lib/puppet/util/settings.rb6
3 files changed, 18 insertions, 4 deletions
diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb
index ac2cc1002..35d6024be 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 ac82975eb..ed0623127 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 3e2020c55..d1e1448cb 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