merge_with_env

View as MarkdownOpen in Claude

Merge the config file with environment variables that match a prefix. Config file values take precedence; environment variables fill in gaps.

Parameters

env_prefix
strDefaults to SWML_

Prefix for environment variables to consider. The prefix is stripped and the remainder is converted to a lowercase config key (e.g., SWML_SSL_ENABLED becomes ssl_enabled).

Returns

dict[str, Any] — Merged configuration dictionary.

Example

1from signalwire.core.config_loader import ConfigLoader
2
3loader = ConfigLoader(["config.json"])
4merged = loader.merge_with_env()
5merged_custom = loader.merge_with_env(env_prefix="MYAPP_")
6
7print(merged)