summaryrefslogtreecommitdiff
path: root/lib/chef/dsl/declare_resource.rb
diff options
context:
space:
mode:
authorAbhishekKr <abhikumar163@gmail.com>2016-07-31 07:42:10 +0530
committerAbhishekKr <abhikumar163@gmail.com>2016-07-31 07:42:10 +0530
commitc3c6cfc156d0a0bfe7c7dd4f273a2c2bdc4b0281 (patch)
treecafccae761432edd05c952f5c8fdb452bfd30ad5 /lib/chef/dsl/declare_resource.rb
parent58e147a9dfa331c359df2c9a2bcc53a27a722ef5 (diff)
parent6b88d8c1bd89f9864478fc873352c2881441dbfe (diff)
downloadchef-c3c6cfc156d0a0bfe7c7dd4f273a2c2bdc4b0281.tar.gz
Merge branch 'master' of https://github.com/chef/chef
Diffstat (limited to 'lib/chef/dsl/declare_resource.rb')
-rw-r--r--lib/chef/dsl/declare_resource.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/chef/dsl/declare_resource.rb b/lib/chef/dsl/declare_resource.rb
index 8d76ddfb31..86227a0f9d 100644
--- a/lib/chef/dsl/declare_resource.rb
+++ b/lib/chef/dsl/declare_resource.rb
@@ -71,7 +71,15 @@ class Chef
# delete_resource!(:template, '/x/y.txy')
#
def delete_resource!(type, name, run_context: self.run_context)
- run_context.resource_collection.delete("#{type}[#{name}]")
+ run_context.resource_collection.delete("#{type}[#{name}]").tap do |resource|
+ # Purge any pending notifications too. This will not raise an exception
+ # if there are no notifications.
+ if resource
+ run_context.before_notification_collection.delete(resource.declared_key)
+ run_context.immediate_notification_collection.delete(resource.declared_key)
+ run_context.delayed_notification_collection.delete(resource.declared_key)
+ end
+ end
end
# Lookup a resource in the resource collection by name and delete it. Returns