Newsie v0.1.0 Newsie.ProviderConfig View Source
Get provider configuration from app config and ENV
Configuration for a provider can be set with app config or with environment variables that follow the naming convention. Environment variables always take precedence application config.
Environment variable naming
Given the application config:
config :newsie, Newsie.Providers.MyNewsProvider, api_key: "asdqwe123"
If you wanted to override that with an environment variable, it would be:
NEWSIE_MY_NEWS_PROVIDER_API_KEY="updated_key"
The provider name and parameter name are snake-cased and prefixed with
NEWSIE_
thus taking on the format:
NEWSIE_<provider_name>_<param_name>
Link to this section Summary
Functions
Get configuration from application config.
Get configuration from ENV vars for the given provider.
Link to this section Functions
Specs
Specs
Get configuration from application config.
Given the app config:
config :newsie, Newsie.Providers.DocProvider, api_key: "mykey"
Fetching the config for the provider:
Newsie.ProviderConfig.provider_app_config(Newsie.Providers.DocProvider)
[api_key: "mykey"]
Specs
Get configuration from ENV vars for the given provider.
Prefixes are stripped and only the parameter names are returned as values.
Example
iex> System.put_env("NEWSIE_DOC_PROVIDER_API_KEY", "mykey")
...> Newsie.ProviderConfig.provider_env_vars("DocProvider")
[api_key: "mykey"]