systeminit / si

The System Initiative software
https://systeminit.com
Apache License 2.0
955 stars 67 forks source link

Only send create/delete events if the resource property is set or unset #4639

Closed jkeiser closed 20 hours ago

jkeiser commented 1 day ago

This makes it so we send the ResourceCreated event anytime a resource payload is added, and ResourceDeleted event when a resource payload is removed. Before this, we triggered ResourceCreated for a Create action, and ResourceDeleted for a Delete action; but if the action fails we still send the event; and if the create has no payload, or some other action has a payload, we send the wrong event or don't send it.

With this code, it doesn't matter what our logic is for whether to add a resource: if there was no resource before and there is one now, it's a create; and if there was a resource before and not after, it's a delete. This way the creates and deletes will exactly match changes in the resource count, which is what we want.

Fixes BUG-576.