[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:12 UTC 2009
The following commit has been merged in the master branch:
commit 7272d49149815e038c67b1ae645b449a1ec2578a
Author: Luke Kanies <luke at madstop.com>
Date: Thu Oct 2 23:07:19 2008 -0500
Fixed #1613 - The client environment will be substituted when looking up settings.
This won't be perfect, because it still requires that the caller pass
in an environment, but for every case that an environment is passed in,
that environment will be substituted into settings when possible.
Signed-off-by: Luke Kanies <luke at madstop.com>
diff --git a/CHANGELOG b/CHANGELOG
index dea6073..bc52d08 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,8 @@
Fixing #1614 - Environments no longer have to be listed out
Fixed #1628 - Changed node search to use certname rather than Facter hostname
+
+ Fixed #1613 - The client environment will be substituted when looking up settings.
Updated puppet binary documentation
diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb
index a8eb090..1e49a3a 100644
--- a/lib/puppet/util/settings.rb
+++ b/lib/puppet/util/settings.rb
@@ -114,12 +114,14 @@ class Puppet::Util::Settings
end
# Do variable interpolation on the value.
- def convert(value)
+ def convert(value, environment = nil)
return value unless value
return value unless value.is_a? String
newval = value.gsub(/\$(\w+)|\$\{(\w+)\}/) do |value|
varname = $2 || $1
- if pval = self.value(varname)
+ if varname == "environment" and environment
+ environment
+ elsif pval = self.value(varname)
pval
else
raise Puppet::DevError, "Could not find value for %s" % value
@@ -781,7 +783,7 @@ Generated on #{Time.now}.
val = @config[param].default if val.nil?
# Convert it if necessary
- val = convert(val)
+ val = convert(val, environment)
# And cache it
@cache[environment||"none"][param] = val
diff --git a/spec/unit/util/settings.rb b/spec/unit/util/settings.rb
index 2a3c2af..313042d 100755
--- a/spec/unit/util/settings.rb
+++ b/spec/unit/util/settings.rb
@@ -249,6 +249,12 @@ describe Puppet::Util::Settings do
@settings.value(:one, "env").should == "envval"
end
+ it "should interpolate found values using the current environment" do
+ @settings.setdefaults :main, :myval => ["$environment/foo", "mydocs"]
+
+ @settings.value(:myval, "myenv").should == "myenv/foo"
+ end
+
it "should return values in a specified environment before values in the main or name sections" do
text = "[env]\none = envval\n[main]\none = mainval\n[myname]\none = nameval\n"
file = "/some/file"
@@ -790,6 +796,7 @@ describe Puppet::Util::Settings do
end
it "should return false if a config param is not found" do
+ @settings.stubs :puts
@settings.stubs(:value).with(:configprint).returns("something")
@settings.stubs(:include?).with("something").returns(false)
@settings.print_configs.should be_false
@@ -797,6 +804,10 @@ describe Puppet::Util::Settings do
end
describe "when genconfig is true" do
+ before do
+ @settings.stubs :puts
+ end
+
it "should call to_config" do
@settings.stubs(:value).with(:genconfig).returns(true)
@settings.expects(:to_config)
@@ -811,6 +822,10 @@ describe Puppet::Util::Settings do
end
describe "when genmanifest is true" do
+ before do
+ @settings.stubs :puts
+ end
+
it "should call to_config" do
@settings.stubs(:value).with(:genmanifest).returns(true)
@settings.expects(:to_manifest)
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list