[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. debian/0.24.6-1-356-g5718585
James Turnbull
james at lovedthanlost.net
Fri Jan 23 14:21:11 UTC 2009
The following commit has been merged in the master branch:
commit 1a9b5677de01fc1ed5a9a6ebbea99a73def7f689
Author: Luke Kanies <luke at madstop.com>
Date: Thu Oct 2 22:56:35 2008 -0500
Fixing #1614 - Environments no longer have to be listed out.
Signed-off-by: Luke Kanies <luke at madstop.com>
diff --git a/CHANGELOG b/CHANGELOG
index 1631700..dea6073 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,6 @@
0.24.x
+ Fixing #1614 - Environments no longer have to be listed out
+
Fixed #1628 - Changed node search to use certname rather than Facter hostname
Updated puppet binary documentation
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb
index a2900fd..e1b6dc4 100644
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@ -122,16 +122,11 @@ module Puppet
namespaces and methods. This can be used as a coarse-grained
authorization system for both ``puppetd`` and ``puppetmasterd``."
],
- :environments => ["production,development", "The valid environments for Puppet clients.
- 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 => {:default => "production", :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.",
- :hook => proc { |value| raise(ArgumentError, "Invalid environment %s" % value) unless Puppet::Node::Environment.valid?(value) }
+ we know nothing about."
},
: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."],
diff --git a/lib/puppet/node/environment.rb b/lib/puppet/node/environment.rb
index 343720a..b64b9c2 100644
--- a/lib/puppet/node/environment.rb
+++ b/lib/puppet/node/environment.rb
@@ -1,30 +1,14 @@
# Model the environment that a node can operate in. This class just
# provides a simple wrapper for the functionality around environments.
class Puppet::Node::Environment
- # Return the list of valid environments. Just looks them up in
- # the settings.
- def self.valid
- # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com]
- x = Puppet.settings.value(:environments).split(",").collect { |e| e.to_sym }
- end
-
- # Is the provided environment valid?
- def self.valid?(name)
- return false if name.to_s == ""
- valid.include?(name.to_sym)
- end
-
@seen = {}
- # Return an existing environment instance, or create a new one,
- # validating the environment name.
+ # Return an existing environment instance, or create a new one.
def self.new(name = nil)
name ||= Puppet.settings.value(:environment)
raise ArgumentError, "Environment name must be specified" unless name
- raise(ArgumentError, "'%s' is not a valid environment" % name) unless valid?(name)
-
symbol = name.to_sym
return @seen[symbol] if @seen[symbol]
diff --git a/spec/unit/node/environment.rb b/spec/unit/node/environment.rb
index 8433a98..872c709 100755
--- a/spec/unit/node/environment.rb
+++ b/spec/unit/node/environment.rb
@@ -5,73 +5,21 @@ require File.dirname(__FILE__) + '/../../spec_helper'
require 'puppet/node/environment'
describe Puppet::Node::Environment do
- it "should provide a list of valid environments" do
- Puppet::Node::Environment.valid.should be_instance_of(Array)
- end
-
- it "should determine its list of valid environments from splitting the :environments setting on commas" do
- Puppet.settings.stubs(:value).with(:environments).returns("one,two")
- Puppet::Node::Environment.valid.collect { |e| e.to_s }.sort.should == %w{one two}.sort
- end
-
- it "should not use an environment when determining the list of valid environments" do
- Puppet.settings.expects(:value).with(:environments).returns("one,two")
- Puppet::Node::Environment.valid
- end
-
- it "should provide a means of identifying invalid environments" do
- Puppet.settings.expects(:value).with(:environments).returns("one,two")
- Puppet::Node::Environment.valid?(:three).should be_false
- end
-
- it "should provide a means of identifying valid environments" do
- Puppet.settings.expects(:value).with(:environments).returns("one,two")
- 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")
Puppet::Node::Environment.new().name.should == :one
end
it "should treat environment instances as singletons" do
- Puppet.settings.stubs(:value).with(:environments).returns("one")
Puppet::Node::Environment.new("one").should equal(Puppet::Node::Environment.new("one"))
end
it "should treat an environment specified as names or strings as equivalent" do
- Puppet.settings.stubs(:value).with(:environments).returns("one")
Puppet::Node::Environment.new(:one).should equal(Puppet::Node::Environment.new("one"))
end
-
- it "should fail if an invalid environment instance is asked for" do
- Puppet.settings.stubs(:value).with(:environments).returns("one,two")
- proc { Puppet::Node::Environment.new("three") }.should raise_error(ArgumentError)
- end
-
- it "should consider environments that are empty strings invalid" do
- Puppet::Node::Environment.valid?("").should be_false
- end
-
- it "should fail if a no-longer-valid environment instance is asked for" do
- Puppet.settings.expects(:value).with(:environments).returns("one")
- Puppet::Node::Environment.new("one")
- Puppet.settings.expects(:value).with(:environments).returns("two")
- proc { Puppet::Node::Environment.new("one") }.should raise_error(ArgumentError)
- end
end
describe Puppet::Node::Environment, " when modeling a specific environment" do
- before do
- Puppet.settings.expects(:value).with(:environments).returns("testing")
- end
-
it "should have a method for returning the environment name" do
Puppet::Node::Environment.new("testing").name.should == :testing
end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list