summaryrefslogtreecommitdiff
path: root/lib/chef/resource.rb
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-12-10 09:18:15 -0800
committerJohn Keiser <john@johnkeiser.com>2015-12-10 14:55:20 -0800
commit1910740592068982a4b6f9ee58452375d60281d5 (patch)
tree58e358d3911f769ea3052a14b8e1bc2747b56378 /lib/chef/resource.rb
parentd8a869814a0cbe1a44ee47e5c3ac1802a8fef2f2 (diff)
downloadchef-1910740592068982a4b6f9ee58452375d60281d5.tar.gz
Warn when user sets a property of an inline resource to itself.
(User will expect "x x" to grab the parent property.)
Diffstat (limited to 'lib/chef/resource.rb')
-rw-r--r--lib/chef/resource.rb21
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 863d357561..4864ad8816 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -569,6 +569,8 @@ class Chef
#
def run_action(action, notification_type=nil, notifying_resource=nil)
# reset state in case of multiple actions on the same resource.
+ old_currently_running_action = @currently_running_action
+ @currently_running_action = action
@elapsed_time = 0
start_time = Time.now
events.resource_action_start(self, action, notification_type, notifying_resource)
@@ -608,16 +610,23 @@ class Chef
events.resource_failed(self, action, e)
raise customize_exception(e)
end
- ensure
- @elapsed_time = Time.now - start_time
- # Reporting endpoint doesn't accept a negative resource duration so set it to 0.
- # A negative value can occur when a resource changes the system time backwards
- @elapsed_time = 0 if @elapsed_time < 0
- events.resource_completed(self)
end
+ ensure
+ @currently_running_action = old_currently_running_action
+ @elapsed_time = Time.now - start_time
+ # Reporting endpoint doesn't accept a negative resource duration so set it to 0.
+ # A negative value can occur when a resource changes the system time backwards
+ @elapsed_time = 0 if @elapsed_time < 0
+ events.resource_completed(self)
end
#
+ # If we are currently running an action, this shows the action we are running.
+ # If the resource is running multiple actions at once, this will show the most recent.
+ #
+ attr_reader :currently_running_action
+
+ #
# Generic Ruby and Data Structure Stuff (for user)
#