use env vars for secrets (ETHICA_TOKEN/HOME/INTERVAL override config)
This commit is contained in:
+10
-6
@@ -309,14 +309,18 @@ def main():
|
||||
print(f"Config not found: {args.config}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
token = cfg.get("token", "")
|
||||
home = cfg.get("home", "https://ethica.no")
|
||||
interval = int(cfg.get("interval", 60))
|
||||
widgets = cfg.get("widgets", [])
|
||||
# Env vars override config file — keeps secrets out of the yml.
|
||||
# ETHICA_TOKEN : company API token (required)
|
||||
# ETHICA_HOME : home URL (optional, default https://ethica.no)
|
||||
# ETHICA_INTERVAL: collection interval in seconds (optional)
|
||||
token = os.environ.get("ETHICA_TOKEN") or cfg.get("token", "")
|
||||
home = os.environ.get("ETHICA_HOME") or cfg.get("home", "https://ethica.no")
|
||||
interval = int(os.environ.get("ETHICA_INTERVAL") or cfg.get("interval", 60))
|
||||
widgets = cfg.get("widgets", [])
|
||||
|
||||
if not token or token == "REPLACE_ME":
|
||||
print("Set 'token' in your config (Company → API in the admin panel).",
|
||||
file=sys.stderr)
|
||||
print("Set ETHICA_TOKEN env var or 'token' in config "
|
||||
"(Company → API tab in the admin panel).", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
if not widgets:
|
||||
print("No widgets configured — nothing to do.", file=sys.stderr)
|
||||
|
||||
Reference in New Issue
Block a user