feat: env var overrides for Mealie/Tandoor connection settings
MEALIE_URL, MEALIE_API_KEY, TANDOOR_URL, TANDOOR_API_KEY env vars now take priority over config.json values when set. Useful for Kubernetes deployments where secrets are injected as env vars. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,10 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v0.8.4 (2026-02-26)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Environment variable overrides for connection settings: `MEALIE_URL`, `MEALIE_API_KEY`, `TANDOOR_URL`, `TANDOOR_API_KEY` — when set, these take priority over values in config.json (useful for Kubernetes deployments)
|
||||||
|
|
||||||
## v0.8.3 (2026-02-24)
|
## v0.8.3 (2026-02-24)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
+18
-1
@@ -19,13 +19,26 @@ _DEFAULTS = {
|
|||||||
"tandoor_api_key": "",
|
"tandoor_api_key": "",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Environment variable overrides for connection settings.
|
||||||
|
# When set, these take priority over values stored in config.json.
|
||||||
|
_ENV_OVERRIDES = {
|
||||||
|
"mealie_url": os.environ.get("MEALIE_URL", "").strip().rstrip("/"),
|
||||||
|
"mealie_api_key": os.environ.get("MEALIE_API_KEY", "").strip(),
|
||||||
|
"tandoor_url": os.environ.get("TANDOOR_URL", "").strip().rstrip("/"),
|
||||||
|
"tandoor_api_key": os.environ.get("TANDOOR_API_KEY", "").strip(),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def _ensure_dir():
|
def _ensure_dir():
|
||||||
DATA_DIR.mkdir(parents=True, exist_ok=True)
|
DATA_DIR.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
|
||||||
def load() -> dict:
|
def load() -> dict:
|
||||||
"""Return the current config dict, merged with defaults."""
|
"""Return the current config dict, merged with defaults.
|
||||||
|
|
||||||
|
Environment variables (MEALIE_URL, MEALIE_API_KEY, TANDOOR_URL,
|
||||||
|
TANDOOR_API_KEY) take priority over file-based values when set.
|
||||||
|
"""
|
||||||
cfg = dict(_DEFAULTS)
|
cfg = dict(_DEFAULTS)
|
||||||
if CONFIG_FILE.exists():
|
if CONFIG_FILE.exists():
|
||||||
try:
|
try:
|
||||||
@@ -33,6 +46,10 @@ def load() -> dict:
|
|||||||
cfg.update(json.load(f))
|
cfg.update(json.load(f))
|
||||||
except (json.JSONDecodeError, OSError):
|
except (json.JSONDecodeError, OSError):
|
||||||
pass
|
pass
|
||||||
|
# Apply env overrides (only non-empty values).
|
||||||
|
for key, val in _ENV_OVERRIDES.items():
|
||||||
|
if val:
|
||||||
|
cfg[key] = val
|
||||||
return cfg
|
return cfg
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user