summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-11-15 19:19:02 -0800
committerMarkus Roberts <Markus@reality.com>2010-11-16 11:10:14 -0800
commitb2ff6a50202a05f2925fa5046a39ef7f163983f1 (patch)
treed2a2d7cb084d0292f8506dc12d490c135d67d6bb
parent1ce00dccb840abd9e11432d00c73bdd1de104751 (diff)
downloadpuppet-b2ff6a50202a05f2925fa5046a39ef7f163983f1.tar.gz
puppet-b2ff6a50202a05f2925fa5046a39ef7f163983f1.tar.xz
puppet-b2ff6a50202a05f2925fa5046a39ef7f163983f1.zip
Fix for #5298 -- Collections need to do type lookup
When the responsibility for type-name resolution was moved to the AST nodes in commit 449315a2c705df2396852462a1d1e14774b9f117, at least one instance was missed: the space ship operator Myclass <<| tag == foo |>> fails unless Myclass has been previously loaded. This commit adds the lookup to AST::Collection nodes in the same way it was added to the other node types. Note that I haven't audited the other note types for similar cases.
-rw-r--r--lib/puppet/parser/ast/collection.rb3
-rwxr-xr-xspec/unit/parser/ast/collection_spec.rb4
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/puppet/parser/ast/collection.rb b/lib/puppet/parser/ast/collection.rb
index 90a914337..ef36b7143 100644
--- a/lib/puppet/parser/ast/collection.rb
+++ b/lib/puppet/parser/ast/collection.rb
@@ -15,7 +15,8 @@ class Puppet::Parser::AST
def evaluate(scope)
str, code = query && query.safeevaluate(scope)
- newcoll = Puppet::Parser::Collector.new(scope, @type, str, code, self.form)
+ resource_type = scope.find_resource_type(@type)
+ newcoll = Puppet::Parser::Collector.new(scope, resource_type.name, str, code, self.form)
scope.compiler.add_collection(newcoll)
diff --git a/spec/unit/parser/ast/collection_spec.rb b/spec/unit/parser/ast/collection_spec.rb
index 3f7878a99..392a2c0f0 100755
--- a/spec/unit/parser/ast/collection_spec.rb
+++ b/spec/unit/parser/ast/collection_spec.rb
@@ -5,6 +5,8 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
describe Puppet::Parser::AST::Collection do
before :each do
@scope = stub_everything 'scope'
+ @mytype = stub_everything('mytype')
+ @scope.stubs(:find_resource_type).returns @mytype
@compiler = stub_everything 'compile'
@scope.stubs(:compiler).returns(@compiler)
@@ -24,6 +26,8 @@ describe Puppet::Parser::AST::Collection do
it "should instantiate a Collector for this type" do
collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "test"
+ @test_type = stub 'type', :name => 'test'
+ @scope.expects(:find_resource_type).with('test').returns @test_type
Puppet::Parser::Collector.expects(:new).with(@scope, "test", nil, nil, :virtual)