From 7d5104702b26ffefd3eba2154e8ae259d750faa7 Mon Sep 17 00:00:00 2001 From: Cyrill Raccaud Date: Sat, 7 Sep 2024 12:03:54 +0200 Subject: [PATCH] Fix white- and blacklist config via docker (#6) > 2.0.1 --- CHANGELOG.md | 4 ++++ docker2mqtt/__init__.py | 2 +- docker2mqtt/__main__.py | 9 +++++---- setup.cfg | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96f8725..1efaef7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 2.0.1 + +* Fix white- and blacklist config via docker env where and empty string resulted in a pass-all regex overwriting the blacklist. + ## 2.0.0 * Rework of the complete structure, but no functional changes. diff --git a/docker2mqtt/__init__.py b/docker2mqtt/__init__.py index 5feb10b..082478c 100644 --- a/docker2mqtt/__init__.py +++ b/docker2mqtt/__init__.py @@ -1,6 +1,6 @@ """docker2mqtt package.""" -__VERSION__ = "2.0.0" +__VERSION__ = "2.0.1" from .const import ( ANSI_ESCAPE, diff --git a/docker2mqtt/__main__.py b/docker2mqtt/__main__.py index b2f678d..5a4fbbd 100755 --- a/docker2mqtt/__main__.py +++ b/docker2mqtt/__main__.py @@ -31,6 +31,9 @@ if __name__ == "__main__": # Env config + whitelist = environ.get("CONTAINER_WHITELIST", "") + blacklist = environ.get("CONTAINER_BLACKLIST", "") + cfg = Docker2MqttConfig( { "log_level": environ.get("LOG_LEVEL", LOG_LEVEL_DEFAULT), @@ -53,10 +56,8 @@ "MQTT_TOPIC_PREFIX", MQTT_TOPIC_PREFIX_DEFAULT ), "mqtt_qos": int(environ.get("MQTT_QOS", MQTT_QOS_DEFAULT)), - "container_whitelist": environ.get("CONTAINER_WHITELIST", "").split(",") - or [], - "container_blacklist": environ.get("CONTAINER_BLACKLIST", "").split(",") - or [], + "container_whitelist": whitelist.split(",") if len(whitelist) > 0 else [], + "container_blacklist": blacklist.split(",") if len(blacklist) > 0 else [], "enable_events": bool(environ.get("EVENTS", EVENTS_DEFAULT)), "enable_stats": bool(environ.get("STATS", STATS_DEFAULT)), "stats_record_seconds": int( diff --git a/setup.cfg b/setup.cfg index 62d9835..43d9e46 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = docker2mqtt -version = 2.0.0 +version = 2.0.1 author = Cyrill Raccaud author_email = cyrill.raccaud+pypi@gmail.com description = Send your docker stats and and events to mqtt and discovery them in home assistant.