diff options
author | Noah Kantrowitz <noah@coderanger.net> | 2016-07-28 18:19:19 -0700 |
---|---|---|
committer | Noah Kantrowitz <noah@coderanger.net> | 2016-07-28 18:19:19 -0700 |
commit | 6a5ad935e3790a2098107594715d075f2fd39d9b (patch) | |
tree | fbeccadeec0436e6e893ef9eadfe1ee768e85aba /lib/chef/dsl | |
parent | 259be7a0cb3f7d7f7ee4d0f49211ddc8d9dcc1b9 (diff) | |
download | chef-6a5ad935e3790a2098107594715d075f2fd39d9b.tar.gz |
Also clear notifications when deleting a resource.
Diffstat (limited to 'lib/chef/dsl')
-rw-r--r-- | lib/chef/dsl/declare_resource.rb | 10 |
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 |