summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2018-08-22 14:15:41 -0700
committerGitHub <noreply@github.com>2018-08-22 14:15:41 -0700
commit927534192d1b79e1d94b860aa3324fe241a39969 (patch)
treeaad752f1b7dc6c8d104b0e0a2b8538a429b9f2b5
parentd9f4d99ea811195d20ddb2997b321de343d01c57 (diff)
parent9010b73b3e9df0d6b5ae01862ec0f83031509376 (diff)
downloadchef-927534192d1b79e1d94b860aa3324fe241a39969.tar.gz
Merge pull request #7566 from chef/lcg/lazy-default-resource-name
lazy the default resource_name until after parsing
-rw-r--r--lib/chef/resource/lwrp_base.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/chef/resource/lwrp_base.rb b/lib/chef/resource/lwrp_base.rb
index c0f6f835ad..ed8a3b205d 100644
--- a/lib/chef/resource/lwrp_base.rb
+++ b/lib/chef/resource/lwrp_base.rb
@@ -49,9 +49,7 @@ class Chef
resource_name = filename_to_qualified_string(cookbook_name, filename)
- # We load the class first to give it a chance to set its own name
resource_class = Class.new(self)
- resource_class.resource_name resource_name.to_sym
resource_class.run_context = run_context
resource_class.class_from_file(filename)
@@ -67,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.resource_name resource_name.to_sym if resource_class.resource_name.nil?
+
resource_class
end