Skip to content

Commit

Permalink
Merge branch '2.7rc' into 2.7.x
Browse files Browse the repository at this point in the history
  • Loading branch information
haus committed Apr 23, 2012
2 parents b8ff039 + 25ad6d7 commit 0ee259f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2.7.14rc2
===
74e462f (#14060) Fix quoting of commands to interpolate inside the shell.
796a072 Modernize the style of the shell exec provider tests.
934ec89 Improve deprecation warning for dynamic lookup

2.7.14rc1
===
0d9e852 Removed duplication of compiling a catalog
Expand Down
4 changes: 3 additions & 1 deletion lib/puppet/parser/scope.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ def lookupvar(name, options = {})
twoscope_value = twoscope_lookupvar(name,options)
if dynamic_value != twoscope_value
location = (options[:file] && options[:line]) ? " at #{options[:file]}:#{options[:line]}" : ''
Puppet.deprecation_warning "Dynamic lookup of $#{name}#{location} is deprecated. Support will be removed in a later version of Puppet. Use a fully-qualified variable name (e.g., $classname::variable) or parameterized classes."
Puppet.deprecation_warning("Dynamic lookup of $#{name}#{location} is deprecated. For more information, see http://docs.puppetlabs.com/guides/scope_and_puppet.html. To see the change in behavior, use the --debug flag.")
Puppet.debug("Currently $#{name} is #{dynamic_value.inspect}")
Puppet.debug("In the future $#{name} will be #{twoscope_value == :undefined ? "undefined" : twoscope_value.inspect}")
end
dynamic_value
end
Expand Down
34 changes: 25 additions & 9 deletions spec/unit/parser/scope_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,31 @@
end

it "should be able to look up intermediary variables in parent scopes (DEPRECATED)" do
Puppet.expects(:deprecation_warning)
thirdscope = Puppet::Parser::Scope.new
thirdscope.parent = @scope
thirdscope.source = Puppet::Resource::Type.new(:hostclass, :foo, :module_name => "foo")
@scope.source = Puppet::Resource::Type.new(:hostclass, :bar, :module_name => "bar")

@topscope.setvar("var2","parentval")
@scope.setvar("var2","childval")
thirdscope.lookupvar("var2").should == "childval"
topscope_value = "parentval"
dynamic_value = "childval"

Puppet.expects(:deprecation_warning).with("Dynamic lookup of $var2 is deprecated. For more information, see http://docs.puppetlabs.com/guides/scope_and_puppet.html. To see the change in behavior, use the --debug flag.")
Puppet.expects(:debug).with("Currently $var2 is #{dynamic_value.inspect}")
Puppet.expects(:debug).with("In the future $var2 will be #{topscope_value.inspect}")

thirdscope = Puppet::Parser::Scope.new(:parent => @scope, :source => Puppet::Resource::Type.new(:hostclass, :foo, :module_name => "foo"))

@topscope.setvar("var2", topscope_value)
@scope.setvar("var2", dynamic_value)
thirdscope.lookupvar("var2").should == dynamic_value
end

it "should call out when the new variable lookup will not find a value (DEPRECATED)" do
dynamic_value = "childval"

Puppet.expects(:deprecation_warning).with("Dynamic lookup of $var2 is deprecated. For more information, see http://docs.puppetlabs.com/guides/scope_and_puppet.html. To see the change in behavior, use the --debug flag.")
Puppet.expects(:debug).with("Currently $var2 is #{dynamic_value.inspect}")
Puppet.expects(:debug).with("In the future $var2 will be undefined")

thirdscope = Puppet::Parser::Scope.new(:parent => @scope, :source => Puppet::Resource::Type.new(:hostclass, :foo, :module_name => "foo"))

@scope.setvar("var2", dynamic_value)
thirdscope.lookupvar("var2").should == dynamic_value
end

describe "and the variable is qualified" do
Expand Down

0 comments on commit 0ee259f

Please sign in to comment.