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

from signalwire.core.config_loader import ConfigLoader
loader = ConfigLoader(["config.json"])
merged = loader.merge_with_env()
merged_custom = loader.merge_with_env(env_prefix="MYAPP_")
print(merged)