Skip to content

Commit

Permalink
feat: use host/user/pass from env vars flyte#406
Browse files Browse the repository at this point in the history
  • Loading branch information
mahnunchik committed Sep 28, 2024
1 parent 4191b17 commit 9464ddd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mqtt_io/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import argparse
import logging.config
import sys
from os import getenv
from copy import deepcopy
from hashlib import sha256
from typing import Any, Optional
Expand Down Expand Up @@ -76,6 +77,16 @@ def main() -> None:
# Load, validate and normalise config, or quit.
try:
raw_config = load_config(args.config, args.render)
if raw_config:
if "mqtt" not in raw_config or raw_config["mqtt"] is None:
raw_config["mqtt"] = {}
raw_config["mqtt"]["host"] = getenv("MQTT_IO_HOST", raw_config["mqtt"].get("host"))
raw_config["mqtt"]["port"] = getenv("MQTT_IO_PORT", raw_config["mqtt"].get("port"))
raw_config["mqtt"]["user"] = getenv("MQTT_IO_USER", raw_config["mqtt"].get("user"))
raw_config["mqtt"]["password"] = getenv("MQTT_IO_PASSWORD",
raw_config["mqtt"].get("password"))
raw_config["mqtt"]["protocol"] = getenv("MQTT_IO_PROTOCOL",
raw_config["mqtt"].get("protocol"))
config = validate_and_normalise_main_config(raw_config)
except ConfigValidationFailed as exc:
print(str(exc), file=sys.stderr)
Expand Down

0 comments on commit 9464ddd

Please sign in to comment.