summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Helwig <jacob@puppetlabs.com>2011-03-08 13:41:48 -0800
committerJacob Helwig <jacob@puppetlabs.com>2011-03-08 13:41:48 -0800
commit2092e61264899c742924a30148ebe1e079b60d38 (patch)
treeeee76afe656ac7b9443b5356fe673fd3cac25789
parent4a8c631a5f909c3e482e087f88cf618e1b44ee4e (diff)
parent64440e58967667426e7294ed38ad16e19812d8c4 (diff)
downloadpuppet-2092e61264899c742924a30148ebe1e079b60d38.tar.gz
puppet-2092e61264899c742924a30148ebe1e079b60d38.tar.xz
puppet-2092e61264899c742924a30148ebe1e079b60d38.zip
Merge branch 'ticket/2.6.x/6513-propigate-environment-in-settings-values' into 2.6.next
* ticket/2.6.x/6513-propigate-environment-in-settings-values: (#6513) Propagate the environment when doing variable lookup in settings (#6513) Adjust P::U::Settings test name to reflect what it tests
-rw-r--r--lib/puppet/util/settings.rb2
-rwxr-xr-xspec/unit/util/settings_spec.rb13
2 files changed, 12 insertions, 3 deletions
diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb
index 626ed20eb..f243b8691 100644
--- a/lib/puppet/util/settings.rb
+++ b/lib/puppet/util/settings.rb
@@ -91,7 +91,7 @@ class Puppet::Util::Settings
varname = $2 || $1
if varname == "environment" and environment
environment
- elsif pval = self.value(varname)
+ elsif pval = self.value(varname, environment)
pval
else
raise Puppet::DevError, "Could not find value for #{value}"
diff --git a/spec/unit/util/settings_spec.rb b/spec/unit/util/settings_spec.rb
index 7bca44b76..07b712c08 100755
--- a/spec/unit/util/settings_spec.rb
+++ b/spec/unit/util/settings_spec.rb
@@ -284,7 +284,8 @@ describe Puppet::Util::Settings do
@settings = Puppet::Util::Settings.new
@settings.setdefaults :section,
:config => ["/my/file", "a"],
- :one => ["ONE", "a"]
+ :one => ["ONE", "a"],
+ :two => ["TWO", "b"]
FileTest.stubs(:exist?).returns true
Puppet.stubs(:run_mode).returns stub('run_mode', :name => :mymode)
end
@@ -331,12 +332,20 @@ describe Puppet::Util::Settings do
@settings.value(:one, "env").should == "envval"
end
- it "should interpolate found values using the current environment" do
+ it 'should use the current environment for $environment' do
@settings.setdefaults :main, :myval => ["$environment/foo", "mydocs"]
@settings.value(:myval, "myenv").should == "myenv/foo"
end
+ it "should interpolate found values using the current environment" do
+ text = "[main]\none = mainval\n[myname]\none = nameval\ntwo = $one/two\n"
+ @settings.stubs(:read_file).returns(text)
+ @settings.parse
+
+ @settings.value(:two, "myname").should == "nameval/two"
+ 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"
@settings.stubs(:read_file).returns(text)