The 'should interpolate found values using the current environment' wasn't actually testing what it was describing, since the environment variable is special cased.
Signed-off-by: Jacob Helwig <ja...@puppetlabs.com> ---
Local branch: ticket/2.6.x/6513-propigate-environment-in-settings-values
diff --git a/spec/unit/util/settings_spec.rb b/spec/unit/util/settings_spec.rb index 7bca44b..3ed843b 100755 --- a/spec/unit/util/settings_spec.rb +++ b/spec/unit/util/settings_spec.rb @@ -331,7 +331,7 @@ 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"]
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) -- 1.7.4.1
> originally produced '/var/lib/puppet/rrd/templates' instead of the > expected '/tmp/env_a/templates'
Jacob, is this actually expanding the list of supported settings in environments?
As I understand it, the only settings that work on a per-environment basis currently are modulepath and manifestdir, and I thought this was a deliberate design decision to push people towards using modules, rather than explicitly having a templatedir, libdir, etc per environment.
I'm not at all convinced yet that every setting available in [master] should be able to be set per [environment].
Nigel Kersten <ni...@puppetlabs.com> wrote: On Sun, Mar 6, 2011 at 12:44 PM, Nigel Kersten <ni...@puppetlabs.com> wrote:
As I understand it, the only settings that work on a per-environment basis currently are modulepath and manifestdir, and I
Correction: modulepath and manifest, not manifestdir.
It's not expanding the list of things that can be set per environment (which currently aren't limited to that list, anyway). It is letting you set your environment modulepath relative to that environment's manifestdir, if you were setting both in the environment. Currently this would not actually Do The Right Thing. -- Sent from my phone. Please excuse my brevity.
> Nigel Kersten <ni...@puppetlabs.com> wrote: > On Sun, Mar 6, 2011 at 12:44 PM, Nigel Kersten <ni...@puppetlabs.com> wrote:
> As I understand it, the only settings that work on a per-environment basis currently are modulepath and manifestdir, and I
> Correction: modulepath and manifest, not manifestdir.
> It's not expanding the list of things that can be set per environment (which currently aren't limited to that list, anyway). It is letting you set your environment modulepath relative to that environment's manifestdir, if you were setting both in the environment. Currently this would not actually Do The Right Thing.
As Jacob said, per-environment settings aren't limited at all any more, and I don't think they have been for the whole 2.6 release series.
-- Always behave like a duck - keep calm and unruffled on the surface but paddle like the devil underneath. -- Jacob Braude --------------------------------------------------------------------- Luke Kanies -|- http://puppetlabs.com -|- +1(615)594-8199
On Sun, Mar 6, 2011 at 2:19 PM, Luke Kanies <l...@puppetlabs.com> wrote:
> As Jacob said, per-environment settings aren't limited at all any more, and > I don't think they have been for the whole 2.6 release series.
Not every setting available in [master] works on a per-environment basis. exec_terminus etc come to mind. Did we document what changed in 2.6.x in this regard?
Nigel Kersten <ni...@puppetlabs.com> wrote: On Sun, Mar 6, 2011 at 2:19 PM, Luke Kanies <l...@puppetlabs.com> wrote:
As Jacob said, per-environment settings aren't limited at all any more, and I don't think they have been for the whole 2.6 release series.
Not every setting available in [master] works on a per-environment basis. exec_terminus etc come to mind. Did we document what changed in 2.6.x in this regard?
-- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
We should probably break this into a separate thread, since this is starting to sound like we've moved on to discussing a separate bug or documentation issue. -- Sent from my phone. Please excuse my brevity.
On Mar 6, 2011, at 3:45 PM, Nigel Kersten <ni...@puppetlabs.com> wrote:
On Sun, Mar 6, 2011 at 2:19 PM, Luke Kanies <l...@puppetlabs.com> wrote:
> As Jacob said, per-environment settings aren't limited at all any more, and > I don't think they have been for the whole 2.6 release series.
Not every setting available in [master] works on a per-environment basis. exec_terminus etc come to mind. Did we document what changed in 2.6.x in this regard?
I agree with Jacob that this is a separate thread, but the short rule is:
All settings support environments, but not all of the code that uses settings does. E.g., anything global like the terminus settings is still, um, global.
It's nearly impossible to document all of these, unfortunately, but we should clearly do a better job.