summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-07-24 10:35:21 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-25 22:24:32 -0700
commit63ec207cc88828b8b0ad421c7fcdd8a5715e7fd3 (patch)
treec20775fa0468fb6a9cc23f33e4dbbff085b07317
parent7ad7eb12fade4695abf08392e80ca57003353140 (diff)
downloadpuppet-63ec207cc88828b8b0ad421c7fcdd8a5715e7fd3.tar.gz
puppet-63ec207cc88828b8b0ad421c7fcdd8a5715e7fd3.tar.xz
puppet-63ec207cc88828b8b0ad421c7fcdd8a5715e7fd3.zip
Minimal fix for #4297, with notes for follow-up
In retrospect it appears that the fix for #4270 was incomplete and somewhat off target. This patch fixes the one demonstrably incorrect part (the namespace) and adds a comment outlining what remains to be done to clean up the code; these additional changes, while needed for maintanability, are inappropriate for a quick turnaround crucial bug fix release such as 2.6.1, at which this patch is targeted.
-rw-r--r--lib/puppet/resource/type.rb19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/puppet/resource/type.rb b/lib/puppet/resource/type.rb
index 85c0979c1..6296d26e5 100644
--- a/lib/puppet/resource/type.rb
+++ b/lib/puppet/resource/type.rb
@@ -174,12 +174,29 @@ class Puppet::Resource::Type
@name.is_a?(Regexp)
end
+ # MQR TODO:
+ #
+ # The change(s) introduced by the fix for #4270 are mostly silly & should be
+ # removed, though we didn't realize it at the time. If it can be established/
+ # ensured that nodes never call parent_type and that resource_types are always
+ # (as they should be) members of exactly one resource_type_collection the
+ # following method could / should be replaced with:
+ #
+ # def parent_type
+ # @parent_type ||= parent && (
+ # resource_type_collection.find_or_load([name],parent,type.to_sym) ||
+ # fail Puppet::ParseError, "Could not find parent resource type '#{parent}' of type #{type} in #{resource_type_collection.environment}"
+ # )
+ # end
+ #
+ # ...and then the rest of the changes around passing in scope reverted.
+ #
def parent_type(scope = nil)
return nil unless parent
unless @parent_type
raise "Must pass scope to parent_type when called first time" unless scope
- unless @parent_type = scope.environment.known_resource_types.send("find_#{type}", scope.namespaces, parent)
+ unless @parent_type = scope.environment.known_resource_types.send("find_#{type}", [name], parent)
fail Puppet::ParseError, "Could not find parent resource type '#{parent}' of type #{type} in #{scope.environment}"
end
end