diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2015-02-03 12:58:19 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-02-03 15:12:48 -0800 |
commit | 3a87159beb91315401a3b88ea847ae6821e0ab88 (patch) | |
tree | 6a982e97f0817702b8ed12c62697ccc38a3974e0 /lib/chef | |
parent | 235622a134cecf6696bcb451038618dc682108cc (diff) | |
download | chef-3a87159beb91315401a3b88ea847ae6821e0ab88.tar.gz |
fix LWRP constant lookups
* providers had the same bug as CHEF-4117 on resources
* removed the strict_const_defined method on Chef::Resource since
ruby 1.8.7 deprecation made that method entirely trivial
* added tests, verified the failure cases really work
* todo added since i think we're leaking state in-between tests
Diffstat (limited to 'lib/chef')
-rw-r--r-- | lib/chef/provider/lwrp_base.rb | 2 | ||||
-rw-r--r-- | lib/chef/resource.rb | 4 | ||||
-rw-r--r-- | lib/chef/resource/lwrp_base.rb | 2 |
3 files changed, 2 insertions, 6 deletions
diff --git a/lib/chef/provider/lwrp_base.rb b/lib/chef/provider/lwrp_base.rb index 121abf5fdb..492ddda6da 100644 --- a/lib/chef/provider/lwrp_base.rb +++ b/lib/chef/provider/lwrp_base.rb @@ -86,7 +86,7 @@ class Chef class_name = convert_to_class_name(provider_name) - if Chef::Provider.const_defined?(class_name) + if Chef::Provider.const_defined?(class_name, false) Chef::Log.info("#{class_name} light-weight provider is already initialized -- Skipping loading #{filename}!") Chef::Log.debug("Overriding already defined LWRPs is not supported anymore starting with Chef 12.") provider_class = Chef::Provider.const_get(class_name) diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index 3e9d119cee..5a6f3ec037 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -931,10 +931,6 @@ class Chef run_context.notifies_delayed(Notification.new(resource_spec, action, self)) end - def self.strict_const_defined?(const) - const_defined?(const, false) - end - class << self # back-compat # NOTE: that we do not support unregistering classes as descendents like diff --git a/lib/chef/resource/lwrp_base.rb b/lib/chef/resource/lwrp_base.rb index 0a1253780c..ce72e98028 100644 --- a/lib/chef/resource/lwrp_base.rb +++ b/lib/chef/resource/lwrp_base.rb @@ -39,7 +39,7 @@ class Chef rname = filename_to_qualified_string(cookbook_name, filename) class_name = convert_to_class_name(rname) - if Resource.strict_const_defined?(class_name) + if Resource.const_defined?(class_name, false) Chef::Log.info("#{class_name} light-weight resource is already initialized -- Skipping loading #{filename}!") Chef::Log.debug("Overriding already defined LWRPs is not supported anymore starting with Chef 12.") resource_class = Resource.const_get(class_name) |