[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5
Nick Lewis
nick at puppetlabs.com
Tue May 10 08:12:49 UTC 2011
The following commit has been merged in the experimental branch:
commit d0a56522f9c574b4a6db81caf4589175c901b09e
Author: Markus Roberts <Markus at reality.com>
Date: Mon Oct 25 09:59:57 2010 -0700
Fix for #5027 -- generate a deprication warning for dynamic lookup
This fix implements the same logic as Nick & Paul's patch in a different way.
There aren't any tests yet and I'm still working out if I agree with the
handling of some edge cases, so this should be considered premliminary.
diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb
index a61a857..dba9440 100644
--- a/lib/puppet/parser/scope.rb
+++ b/lib/puppet/parser/scope.rb
@@ -236,9 +236,13 @@ class Puppet::Parser::Scope
end
elsif ephemeral_include?(name) or table.include?(name)
# We can't use "if table[name]" here because the value might be false
+ if options[:dynamic] and self != compiler.topscope
+ location = (options[:file] && options[:line]) ? " at #{options[:file]}:#{options[:line]}" : ''
+ Puppet.deprication_warning "Dynamic lookup of $#{name}#{location} will not be supported in future versions. Use a fully-qualified variable name or parameterized classes."
+ end
table[name]
elsif parent
- parent.lookupvar(name,options)
+ parent.lookupvar(name,options.merge(:dynamic => (dynamic || options[:dynamic])))
else
:undefined
end
diff --git a/spec/unit/parser/ast/leaf_spec.rb b/spec/unit/parser/ast/leaf_spec.rb
index 64fdcd6..cd09eaf 100755
--- a/spec/unit/parser/ast/leaf_spec.rb
+++ b/spec/unit/parser/ast/leaf_spec.rb
@@ -137,7 +137,7 @@ describe Puppet::Parser::AST::HashOrArrayAccess do
end
it "should be able to return an array member when index is a stringified number" do
- @scope.stubs(:lookupvar).with("a").returns(["val1", "val2", "val3"])
+ @scope.stubs(:lookupvar).with { |name,options| name == "a" }.returns(["val1", "val2", "val3"])
access = Puppet::Parser::AST::HashOrArrayAccess.new(:variable => "a", :key => "1" )
@@ -145,7 +145,7 @@ describe Puppet::Parser::AST::HashOrArrayAccess do
end
it "should raise an error when accessing an array with a key" do
- @scope.stubs(:lookupvar).with("a").returns(["val1", "val2", "val3"])
+ @scope.stubs(:lookupvar).with { |name,options| name == "a"}.returns(["val1", "val2", "val3"])
access = Puppet::Parser::AST::HashOrArrayAccess.new(:variable => "a", :key => "get_me_the_second_element_please" )
@@ -161,7 +161,7 @@ describe Puppet::Parser::AST::HashOrArrayAccess do
end
it "should be able to return an hash value with a numerical key" do
- @scope.stubs(:lookupvar).with("a").returns({ "key1" => "val1", "key2" => "val2", "45" => "45", "key3" => "val3" })
+ @scope.stubs(:lookupvar).with { |name,options| name == "a"}.returns({ "key1" => "val1", "key2" => "val2", "45" => "45", "key3" => "val3" })
access = Puppet::Parser::AST::HashOrArrayAccess.new(:variable => "a", :key => "45" )
@@ -169,7 +169,7 @@ describe Puppet::Parser::AST::HashOrArrayAccess do
end
it "should raise an error if the variable lookup didn't return an hash or an array" do
- @scope.stubs(:lookupvar).with("a").returns("I'm a string")
+ @scope.stubs(:lookupvar).with { |name,options| name == "a"}.returns("I'm a string")
access = Puppet::Parser::AST::HashOrArrayAccess.new(:variable => "a", :key => "key2" )
@@ -220,7 +220,7 @@ describe Puppet::Parser::AST::HashOrArrayAccess do
end
it "should raise an error when assigning an array element with a key" do
- @scope.stubs(:lookupvar).with("a").returns([])
+ @scope.stubs(:lookupvar).with { |name,options| name == "a"}.returns([])
access = Puppet::Parser::AST::HashOrArrayAccess.new(:variable => "a", :key => "get_me_the_second_element_please" )
@@ -238,7 +238,7 @@ describe Puppet::Parser::AST::HashOrArrayAccess do
end
it "should raise an error when trying to overwrite an hash value" do
- @scope.stubs(:lookupvar).with("a").returns({ "key" => [ "a" , "b" ]})
+ @scope.stubs(:lookupvar).with { |name,options| name == "a" }.returns({ "key" => [ "a" , "b" ]})
access = Puppet::Parser::AST::HashOrArrayAccess.new(:variable => "a", :key => "key")
lambda { access.assign(@scope, "test") }.should raise_error
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list