diff options
author | Jesse Wolfe <jes5199@gmail.com> | 2010-08-02 17:23:36 -0700 |
---|---|---|
committer | markus <markus@AVA-351181.(none)> | 2010-08-03 15:19:34 -0700 |
commit | 1faebdd7b54a55b023f151976644dbc3405c486b (patch) | |
tree | 5cc6f2cdcd0a0164b9fbd15a03d6e653eb824dff /lib | |
parent | 37568bdd3f8cc3514eb9d0bf0eae3302686bc13d (diff) | |
download | puppet-1faebdd7b54a55b023f151976644dbc3405c486b.tar.gz puppet-1faebdd7b54a55b023f151976644dbc3405c486b.tar.xz puppet-1faebdd7b54a55b023f151976644dbc3405c486b.zip |
[#4423] repair parameterized class instantiation
My earlier #4397 patch was not aware of the parameterized class
instantiation syntax, and failed on manifests that instantiate
parameterized classes.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/parser/ast/resource.rb | 5 | ||||
-rw-r--r-- | lib/puppet/parser/ast/resource_reference.rb | 16 | ||||
-rw-r--r-- | lib/puppet/parser/scope.rb | 21 |
3 files changed, 25 insertions, 17 deletions
diff --git a/lib/puppet/parser/ast/resource.rb b/lib/puppet/parser/ast/resource.rb index 9149b06c3..0c58538d5 100644 --- a/lib/puppet/parser/ast/resource.rb +++ b/lib/puppet/parser/ast/resource.rb @@ -33,11 +33,12 @@ class Resource < AST::ResourceReference # This is where our implicit iteration takes place; if someone # passed an array as the name, then we act just like the called us # many times. - resource_type = scope.find_resource_type(type) + fully_qualified_type, resource_titles = scope.resolve_type_and_titles(type, resource_titles) + resource_titles.flatten.collect { |resource_title| exceptwrap :type => Puppet::ParseError do resource = Puppet::Parser::Resource.new( - resource_type.name, resource_title, + fully_qualified_type, resource_title, :parameters => paramobjects, :file => self.file, :line => self.line, diff --git a/lib/puppet/parser/ast/resource_reference.rb b/lib/puppet/parser/ast/resource_reference.rb index 5b1b0aa3a..0f8e655bf 100644 --- a/lib/puppet/parser/ast/resource_reference.rb +++ b/lib/puppet/parser/ast/resource_reference.rb @@ -7,23 +7,9 @@ class Puppet::Parser::AST::ResourceReference < Puppet::Parser::AST::Branch # Evaluate our object, but just return a simple array of the type # and name. def evaluate(scope) - a_type = type titles = Array(title.safeevaluate(scope)) - case type.downcase - when "class" - # resolve the titles - titles = titles.collect do |a_title| - hostclass = scope.find_hostclass(a_title) - hostclass ? hostclass.name : a_title - end - when "node" - # no-op - else - # resolve the type - resource_type = scope.find_resource_type(type) - a_type = resource_type.name if resource_type - end + a_type, titles = scope.resolve_type_and_titles(type, titles) resources = titles.collect{ |a_title| Puppet::Resource.new(a_type, a_title) diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb index 2ca28d824..24f1d01f7 100644 --- a/lib/puppet/parser/scope.rb +++ b/lib/puppet/parser/scope.rb @@ -488,6 +488,27 @@ class Puppet::Parser::Scope environment.known_resource_types.find_definition(namespaces, type.to_s.downcase) end + def resolve_type_and_titles(type, titles) + raise ArgumentError, "titles must be an array" unless titles.is_a?(Array) + + case type.downcase + when "class" + # resolve the titles + titles = titles.collect do |a_title| + hostclass = find_hostclass(a_title) + hostclass ? hostclass.name : a_title + end + when "node" + # no-op + else + # resolve the type + resource_type = find_resource_type(type) + type = resource_type.name if resource_type + end + + return [type, titles] + end + private def extend_with_functions_module |