Skip to content

Commit

Permalink
fix the container filter not only at startup but also at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
miaucl committed Sep 8, 2024
1 parent fddfe6a commit 7f168a6
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions docker2mqtt/docker2mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,14 +888,15 @@ def _handle_events_queue(self) -> None:
)
del self.pending_destroy_operations[container]

self._register_container(
{
"name": container,
"image": event["from"],
"status": "created",
"state": "off",
}
)
if self._filter_container(container):
self._register_container(
{
"name": container,
"image": event["from"],
"status": "created",
"state": "off",
}
)

elif event["status"] == "destroy":
# Add this container to pending_destroy_operations.
Expand Down Expand Up @@ -924,16 +925,21 @@ def _handle_events_queue(self) -> None:
"Container %s renamed to %s.", old_name, container
)
self._unregister_container(old_name)
self._register_container(
{
"name": container,
"image": self.known_event_containers[old_name]["image"],
"status": self.known_event_containers[old_name][
"status"
],
"state": self.known_event_containers[old_name]["state"],
}
)
if self._filter_container(container):
self._register_container(
{
"name": container,
"image": self.known_event_containers[old_name][
"image"
],
"status": self.known_event_containers[old_name][
"status"
],
"state": self.known_event_containers[old_name][
"state"
],
}
)
del self.known_event_containers[old_name]

elif event["status"] == "start":
Expand Down

0 comments on commit 7f168a6

Please sign in to comment.