From b22d148e6d6eb36c9b02a58dc0c04c9650d5207b Mon Sep 17 00:00:00 2001 From: Brice Figureau Date: Thu, 5 Feb 2009 19:59:18 +0100 Subject: Fix #1691 - Realize fails with array of Resource References The following snippet: realize( File["/tmp/a","/tmp/b"] ) is parsed into: AST::Function @name=realize @arguments= AST::ASTArray @children = [ AST::ResourceReference @title= AST::ASTArray @children = [ String(/tmp/a), String(/tmp/b) ] ] When evaluated: ResourceReference gives -> [ File[/tmp/a], File[/tmp/b] ] which means the function arguments are: [[File[/tmp/a], File[/tmp/b]] after evaluating the @arguments ASTArray of AST::Functions. Then the collector complains that it can't find the resource because it is not supposed to work on non-flattened resource array. The fix is to flatten in the realize function (although it can be done more generally in the AST::Function evaluation) before the resources are given to the Collector. Signed-off-by: Brice Figureau --- lib/puppet/parser/functions/realize.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/puppet/parser/functions') diff --git a/lib/puppet/parser/functions/realize.rb b/lib/puppet/parser/functions/realize.rb index 1bdde234e..6aff19d29 100644 --- a/lib/puppet/parser/functions/realize.rb +++ b/lib/puppet/parser/functions/realize.rb @@ -8,7 +8,7 @@ Puppet::Parser::Functions::newfunction(:realize, :doc => "Make a virtual object reference; e.g.: ``realize User[luke]``." ) do |vals| coll = Puppet::Parser::Collector.new(self, :nomatter, nil, nil, :virtual) vals = [vals] unless vals.is_a?(Array) - coll.resources = vals + coll.resources = vals.flatten compiler.add_collection(coll) end -- cgit