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-07-10 12:56:42 -0700
commit5826f7399325c784a5e8e33c7fabc46e202334a8 (patch)
treed5a5060944d69303deda8ce7b0b8fd85b853b747 /lib/puppet/parser/functions
parentd58eacd6b4abc804bc5326184ed59c309fd04149 (diff)
downloadpuppet-5826f7399325c784a5e8e33c7fabc46e202334a8.tar.gz
puppet-5826f7399325c784a5e8e33c7fabc46e202334a8.tar.xz
puppet-5826f7399325c784a5e8e33c7fabc46e202334a8.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)