From 2a914b78f2234502274422ffbef2a86d88aa60b1 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 20 2019 14:14:46 +0000 Subject: Allow specify a parent topic to all the mqtt notifications sent Signed-off-by: Pierre-Yves Chibon --- diff --git a/doc/configuration.rst b/doc/configuration.rst index df4e8cc..5544444 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -1904,6 +1904,17 @@ configuration key to specify the ciphers. Defaults to: ``None`` + +MQTT_TOPIC_PREFIX +~~~~~~~~~~~~~~~~~ + +This configuration key allows to specify a prefix to the mqtt messages sent. +This prefix will be added to the topic used by pagure thus allowing the mqtt +admins to specify a parent topic for all pagure-related messages. + +Defaults to: ``None`` + + ALWAYS_MQTT_ON_COMMITS ~~~~~~~~~~~~~~~~~~~~~~ diff --git a/pagure/lib/notify.py b/pagure/lib/notify.py index da35cd3..a053dac 100644 --- a/pagure/lib/notify.py +++ b/pagure/lib/notify.py @@ -150,6 +150,10 @@ def mqtt_publish(topic, message): ) mqtt_ciphers = pagure_config.get("MQTT_CIPHERS") + mqtt_topic_prefix = pagure_config.get("MQTT_TOPIC_PREFIX") or None + if mqtt_topic_prefix: + topic = "/".join([mqtt_topic_prefix.rstrip("/"), topic]) + # We catch Exception if we want :-p # pylint: disable=broad-except # Ignore message about mqtt import