summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/functions
diff options
context:
space:
mode:
authorJeff McCune <jeff@puppetlabs.com>2011-06-21 18:54:35 -0700
committerJeff McCune <jeff@puppetlabs.com>2011-06-21 18:54:35 -0700
commita126aee16294b183d2c6068b46ad8e394d2d95f8 (patch)
tree505659a6dccd3f084ae0afc9f43893ca34e8d2e8 /lib/puppet/parser/functions
parentcf93404e53aa32ac4a919ddd57d09ed78abfc1b5 (diff)
downloadpuppet-a126aee16294b183d2c6068b46ad8e394d2d95f8.tar.gz
puppet-a126aee16294b183d2c6068b46ad8e394d2d95f8.tar.xz
puppet-a126aee16294b183d2c6068b46ad8e394d2d95f8.zip
(#8032) Add containment to create_resources
Without this change native resource types declared using the create_resources() function are not contained within the class scope of the function call. As a result, resources were "floating off" in the graph, disconnected from the rest of the relationship edges. With this change, the scope is preserved and native resources are contained by the class the function call is executed from. Reviewed-by: Dan Bode <dan@puppetlabs.com>
Diffstat (limited to 'lib/puppet/parser/functions')
-rw-r--r--lib/puppet/parser/functions/create_resources.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/puppet/parser/functions/create_resources.rb b/lib/puppet/parser/functions/create_resources.rb
index 430f110b4..3b8bb3543 100644
--- a/lib/puppet/parser/functions/create_resources.rb
+++ b/lib/puppet/parser/functions/create_resources.rb
@@ -27,15 +27,16 @@ Takes two parameters:
args[1].each do |title, params|
raise ArgumentError, 'params should not contain title' if(params['title'])
case type_of_resource
- when :type
- res = resource.hash2resource(params.merge(:title => title))
- catalog.add_resource(res)
- when :define
+ # JJM The only difference between a type and a define is the call to instantiate_resource
+ # for a defined type.
+ when :type, :define
p_resource = Puppet::Parser::Resource.new(type_name, title, :scope => self, :source => resource)
params.merge(:name => title).each do |k,v|
p_resource.set_parameter(k,v)
end
- resource.instantiate_resource(self, p_resource)
+ if type_of_resource == :define then
+ resource.instantiate_resource(self, p_resource)
+ end
compiler.add_resource(self, p_resource)
when :class
klass = find_hostclass(title)