summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2020-03-24 20:09:55 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2020-03-26 11:59:07 -0700
commitc598c15afc988cc7d312e06e6f522daa45230d39 (patch)
tree30338146b8ab81cab4a6a0510c9107decc9a8e1f
parent24b04cc0cd19b2b17a185b138d204778fe009b08 (diff)
downloadchef-lcg/restore-magic-resource-name-order.tar.gz
restore magic resource name orderinglcg/restore-magic-resource-name-order
this restores the order that the magic wiring of LWRP / custom resources to the cookbook_name + resource filename comes after the parsing of the file that it is defined in. i had moved this because i was running into issues with recursive calls between provides and the resource_name method, which i later solved. this restores the prior behavior, but calls provides instead of resource_name, but relies on the implicit call to resource_name from the first provides to be functionally identical to the prior behavior anyway. no idea if this actually fixes any bugs, but it was not really intentional to change it. stuff like chef_version_for_provides needs to be called before calling provides, so it seems like the behavior this fixes should have been buggy with respect to that but it is obviously... complicated. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--lib/chef/resource/lwrp_base.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/chef/resource/lwrp_base.rb b/lib/chef/resource/lwrp_base.rb
index 152482434f..c5887e5104 100644
--- a/lib/chef/resource/lwrp_base.rb
+++ b/lib/chef/resource/lwrp_base.rb
@@ -51,7 +51,6 @@ class Chef
resource_class = Class.new(self)
resource_class.run_context = run_context
- resource_class.provides resource_name.to_sym
resource_class.class_from_file(filename)
# Make a useful string for the class (rather than <Class:312894723894>)
@@ -66,6 +65,10 @@ class Chef
LWRPBase.loaded_lwrps[filename] = true
+ # wire up the default resource name after the class is parsed only if we haven't declared one.
+ # (this ordering is important for MapCollision deprecation warnings)
+ resource_class.provides resource_name.to_sym unless Chef::ResourceResolver.includes_handler?(resource_name.to_sym, self)
+
resource_class
end