summaryrefslogtreecommitdiff
path: root/lib/chef/platform
diff options
context:
space:
mode:
authorChristian Höltje <docwhat@gerf.org>2015-07-13 15:35:54 -0400
committerChristian Höltje <docwhat@gerf.org>2015-08-19 15:30:07 -0400
commit82f328a811bf4c8a71277d56bfffa631d5f565f5 (patch)
tree966d798a584a9c5ed851df311d3cd3dc15af1d53 /lib/chef/platform
parentbacb2ff93ccc2e14a0b721988e241a1d07f70795 (diff)
downloadchef-82f328a811bf4c8a71277d56bfffa631d5f565f5.tar.gz
Fix error message for providers without `provides`
The warning incorrectly said that the provider was missing `resource_name :resource` when it should have said it was missing `provides :resource` I also switched from using `begin`...`rescue` since it isn't needed and needlessly slow things up. Fixes #3614
Diffstat (limited to 'lib/chef/platform')
-rw-r--r--lib/chef/platform/provider_mapping.rb11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/chef/platform/provider_mapping.rb b/lib/chef/platform/provider_mapping.rb
index 38dd0e38af..9b511f0237 100644
--- a/lib/chef/platform/provider_mapping.rb
+++ b/lib/chef/platform/provider_mapping.rb
@@ -200,14 +200,13 @@ class Chef
class_name = resource_type.class.name ? resource_type.class.name.split('::').last :
convert_to_class_name(resource_type.resource_name.to_s)
- begin
- result = Chef::Provider.const_get(class_name)
- Chef::Log.warn("Class Chef::Provider::#{class_name} does not declare 'resource_name #{convert_to_snake_case(class_name).to_sym.inspect}'.")
- Chef::Log.warn("This will no longer work in Chef 13: you must use 'resource_name' to provide DSL.")
- rescue NameError
+ if Chef::Provider.const_defined?(class_name)
+ Chef::Log.warn("Class Chef::Provider::#{class_name} does not declare 'provides #{convert_to_snake_case(class_name).to_sym.inspect}'.")
+ Chef::Log.warn("This will no longer work in Chef 13: you must use 'provides' to use the resource's DSL.")
+ return Chef::Provider.const_get(class_name)
end
end
- result
+ nil
end
end