distillery v2.0.0-rc.10 Mix.Releases.Config.Providers.Elixir View Source

Provides support for Mix.Config config scripts, e.g. config.exs

This provider expects a path to a config file to load during boot as an argument:

set config_providers: [
  {Mix.Releases.Config.Providers.Elixir, ["${RELEASE_ROOT_DIR}/config.exs"]}
]

The above configuration goes in a release or environment definition in rel/congfig.exs, and will result in the given path being expanded during boot, and evaluated using Mix.Config.

Caveats

Because much of Mix assumes it is operating in a Mix project context, there are some things you need to be aware of when using Mix.Config in releases:

  • Mix APIs, other than Mix.Config itself, are not guaranteed to work, and most do not. This provider starts Mix when the provider runs, so you can call Mix.env, but it is an exception to the rule. Other functions are unlikely to work, so you should not rely on them being available.
  • Mix.env always returns :prod, unless MIX_ENV is exported in the environment, in which case that value is used instead.
  • The Mix project context is unavailable, as is your build environment, so Mix configs which invoke git or otherwise depend on that context, are not going to work. You need to use configs which are pared down to only reference the target environment (in general configs should be small anyway).

Link to this section Summary

Functions

Called when the provider is being asked to supply a value for the given key

Link to this section Functions

Called when the provider is being asked to supply a value for the given key

Keys supplied to providers are a list of atoms which represent the path of the configuration key, beginning with the application name:

NOTE: This is currently unused, but provides an API for fetching config values from specific providers, which may come in handy down the road. A default implementation is provided for you, which fetches values from the application environment.

Examples

> MyProvider.get([:myapp, :server, :port])
{:ok, 8080}

> MyProvider.get([:maypp, :invalid, :key])
nil

Callback implementation for Mix.Releases.Config.Provider.get/1.

Link to this function merge_config(runtime_config) View Source