summaryrefslogtreecommitdiff
path: root/lib/chef/property.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/property.rb')
-rw-r--r--lib/chef/property.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/chef/property.rb b/lib/chef/property.rb
index 3c40c020b6..9aaa49c313 100644
--- a/lib/chef/property.rb
+++ b/lib/chef/property.rb
@@ -292,6 +292,16 @@ class Chef
value
else
+ # If we are still compiling this resource (rather than running an action
+ # on it), reading this property before it's been set is likely the wrong
+ # thing. Warn if it's a duplicate of the enclosing provider.
+ if resource.respond_to?(:enclosing_provider) && resource.enclosing_provider &&
+ !resource.currently_running_action &&
+ !name_property? &&
+ resource.enclosing_provider.respond_to?(name)
+ Chef::Log.warn("#{Chef::Log.caller_location}: property #{name} is declared in both #{resource} and #{resource.enclosing_provider}. Use new_resource.#{name} instead. At #{Chef::Log.caller_location}")
+ end
+
if has_default?
value = default
if value.is_a?(DelayedEvaluator)