summaryrefslogtreecommitdiff
path: root/lib/puppet/parser/functions/defined_with_params.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/parser/functions/defined_with_params.rb')
-rw-r--r--lib/puppet/parser/functions/defined_with_params.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/puppet/parser/functions/defined_with_params.rb b/lib/puppet/parser/functions/defined_with_params.rb
index 99687ae..c45a9df 100644
--- a/lib/puppet/parser/functions/defined_with_params.rb
+++ b/lib/puppet/parser/functions/defined_with_params.rb
@@ -24,7 +24,25 @@ ENDOFDOC
params = {}
end
ret = false
- if resource = findresource(reference.to_s)
+
+ if Puppet::Util::Package.versioncmp(Puppet.version, '4.6.0') >= 0
+ # Workaround for PE-20308
+ if reference.is_a?(String)
+ type_name, title = Puppet::Resource.type_and_title(reference, nil)
+ type = Puppet::Pops::Evaluator::Runtime3ResourceSupport.find_resource_type_or_class(find_global_scope, type_name.downcase)
+ elsif reference.is_a?(Puppet::Resource)
+ type = reference.resource_type
+ title = reference.title
+ else
+ raise(ArgumentError, "Reference is not understood: '#{reference.class}'")
+ end
+ #end workaround
+ else
+ type = reference.to_s
+ title = nil
+ end
+
+ if resource = findresource(type, title)
matches = params.collect do |key, value|
# eql? avoids bugs caused by monkeypatching in puppet
resource_is_undef = resource[key].eql?(:undef) || resource[key].nil?