[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 2.6.5-303-gfcfa26a

Jacob Helwig jacob at puppetlabs.com
Thu Mar 17 10:49:00 UTC 2011


The following commit has been merged in the upstream branch:
commit 64440e58967667426e7294ed38ad16e19812d8c4
Author: Jacob Helwig <jacob at puppetlabs.com>
Date:   Sat Mar 5 12:39:14 2011 -0600

    (#6513) Propagate the environment when doing variable lookup in settings
    
    For example with the following:
    
    test.conf:
      [master]
          rrddir = /var/lib/puppet/rrd
          templatedir = /var/lib/puppet/templates
      [env_a]
          templatedir = $rrddir/templates
          rrddir = /tmp/env_a/
    
    The command:
      RUBYLIB=lib bin/puppet master --config ./test.conf --environment env_a --configprint templatedir
    
    originally produced '/var/lib/puppet/rrd/templates' instead of the
    expected '/tmp/env_a/templates'
    
    Reviewed-by: Jesse Wolfe <jesse at puppetlabs.com>

diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb
index 626ed20..f243b86 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 3ed843b..07b712c 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
@@ -337,6 +338,14 @@ describe Puppet::Util::Settings do
       @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)

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list