Rivet.Utils.JsonConfigProvider (rivet_utils v2.0.8)

View Source

Derived from toml-elixir/Toml.Provider https://github.com/bitwalker/toml-elixir/blob/master/lib/provider.ex and https://hexdocs.pm/elixir/Config.Provider.html#module-sample-config-provider

This is a runtime config provider (for 12factor apps).

It will merge json data into the config structure.

In Elixir Config: config :app, That.Module, the: thing

In Elixir (Raw)

Application.get_env(:app, That.Module) [{ the: "thing" }]

In JSON, you have two special syntaxes to the keys:

  1. prefix 'Elixir.' on the module name if it's an elixir module:

{"app": {"Elixir.That.Module": {"the": "thing"}}}

  1. use "$NAME:name" as the key and it will pull that value at runtime from the OS environment[NAME], saving it as [name] in the current heirarchial location of the config file, defaulting the value to whatever is set in the static variable instead.

Contributor: Brandon Gillespie

Summary

Functions

Callback implementation for Config.Provider.init/1.

iex> keyword_pair("doctor", "who")

Callback implementation for Config.Provider.load/2.

Functions

expand_path(path)

init(p)

Callback implementation for Config.Provider.init/1.

keyword_pair(k, v_default)

iex> keyword_pair("doctor", "who")

iex> keyword_pair("$DOCTOR:doctor", "who")

iex> keyword_pair("$DOCTOR_TEST_ENV", "who")

iex> System.put_env("DOCTOR_TEST_ENV", "WHO") iex> keyword_pair("$DOCTOR_TEST_ENV:doctor", "who")

iex> keyword_pair("${DOCTOR_TEST_ENV}", "who")

iex> keyword_pair("${DOCTOR_TEST_ENV", "WHO") ** (RuntimeError) Invalid environment key `${DOCTOR_TEST_ENV`

load(config, default_path)

Callback implementation for Config.Provider.load/2.