diff options
author | Luke Kanies <luke@madstop.com> | 2007-11-19 23:27:07 -0600 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2007-11-19 23:27:07 -0600 |
commit | 53008e567fd64f391e0b45652b2f4ac1551ccf47 (patch) | |
tree | a67926faf1e9599af2c60fde3c005b2f7118925d | |
parent | 9e5fc76eb77a9b90afb384d34a8e5bf63f79af6e (diff) | |
download | puppet-53008e567fd64f391e0b45652b2f4ac1551ccf47.tar.gz puppet-53008e567fd64f391e0b45652b2f4ac1551ccf47.tar.xz puppet-53008e567fd64f391e0b45652b2f4ac1551ccf47.zip |
The Puppet settings instance now validates environments when
you set an environment.
-rw-r--r-- | lib/puppet/defaults.rb | 6 | ||||
-rwxr-xr-x | spec/unit/node/environment.rb | 5 |
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index da830952a..400cc98fd 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -131,11 +131,13 @@ module Puppet This is more useful as a server-side setting than client, but any environment chosen must be in this list. Values should be separated by a comma."], - :environment => ["development", "The environment Puppet is running in. For clients + :environment => {:default => "development", :desc => "The environment Puppet is running in. For clients (e.g., ``puppetd``) this determines the environment itself, which is used to find modules and much more. For servers (i.e., ``puppetmasterd``) this provides the default environment for nodes - we know nothing about."], + we know nothing about.", + :hook => proc { |value| raise(ArgumentError, "Invalid environment %s" % value) unless Puppet::Node::Environment.valid?(value) } + }, :diff_args => ["", "Which arguments to pass to the diff command when printing differences between files."], :diff => ["diff", "Which diff command to use when printing differences between files."], :show_diff => [false, "Whether to print a contextual diff when files are being replaced. The diff diff --git a/spec/unit/node/environment.rb b/spec/unit/node/environment.rb index cccff7b97..69d7acb47 100755 --- a/spec/unit/node/environment.rb +++ b/spec/unit/node/environment.rb @@ -29,6 +29,11 @@ describe Puppet::Node::Environment do Puppet::Node::Environment.valid?(:one).should be_true end + it "should be used to determine when an environment setting is valid" do + Puppet.settings.expects(:value).with(:environments).returns("one,two") + proc { Puppet.settings[:environment] = :three }.should raise_error(ArgumentError) + end + it "should use the default environment if no name is provided while initializing an environment" do Puppet.settings.expects(:value).with(:environments).returns("one,two") Puppet.settings.expects(:value).with(:environment).returns("one") |