summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG2
-rw-r--r--lib/puppet/util/settings.rb8
-rwxr-xr-xspec/unit/util/settings.rb15
3 files changed, 22 insertions, 3 deletions
diff --git a/CHANGELOG b/CHANGELOG
index dea60731e..bc52d08d9 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 a8eb09049..1e49a3ada 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 2a3c2afc7..313042d65 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)