config_tuples v0.2.3 ConfigTuples.Provider View Source
This module provides an implementation of Distilery’s configuration provider behavior that changes runtime config tuples for the value.
Usage
Add the following to your rel/config.exs
release :myapp do
# ...snip...
set config_providers: [
ConfigTuples.Provider
]
end
This will result in ConfigTuples.Provider
being invoked during boot, at which point it
will evaluate the current configuration for all the apps and replace the config tuples when needed, persisting it in the configuration.
Config tuples
The config tuple always start with :system
, and can have some options as keyword, the syntax are like this:
{:system, env_name}
{:system, env_name, opts}
The available options are:
type
: Type to cast the value, one of:string
,:integer
,:atom
,:boolean
. Default to:string
default
: Default value if the environment variable is not setted. Default nonil
transform
: Function to transform the final value, the syntax is {Module, :function}
For example:
{:system, "MYSQL_PORT", type: :integer, default: 3306}
{:system, "ENABLE_LOG", type: :boolean, default: false}
{:system, "HOST", transform: {MyApp.UrlParser, :parse}}