Kaur v1.1.0 Kaur.Environment View Source

Utilities for working with configuration allowing environment variables.

  • {:system, something}: will load the environment variable stored in something
  • value: will return the value

Link to this section Summary

Functions

Reads the value or environment variable for the key in application’s environment

Reads the value or environment variable for the key in application’s environment

Link to this section Functions

Link to this function read(application, key) View Source
read(:atom, :atom) :: Kaur.Result.result_tuple

Reads the value or environment variable for the key in application’s environment.

Examples

If we imagine a config file like:

# config/config.exs
config :my_app, :my_key, {:system, "MY_KEY"}
config :my_app, :my_key2, "MY_VALUE"

iex> Kaur.Environment.read(:my_app, :my_key)
{:ok, "VALUE STORE IN MY_KEY"}

iex> Kaur.Environment.read(:my_app, :my_key2)
{:ok, "MY VALUE"}

iex> Kaur.Environment.read(:my_app, :something_else)
{:error, :no_value}
Link to this function read(application, key, sub_keys) View Source
read(:atom, :atom, [:atom]) :: Kaur.Result.result_tuple

Reads the value or environment variable for the key in application’s environment.

Examples

If we imagine a config file like:

# config/config.exs
config :my_app, :my_key, secret: {:system, "MY_KEY"}
config :my_app, :my_key2, secret: "MY_VALUE"

iex> Kaur.Environment.read(:my_app, :my_key, [:secret])
{:ok, "VALUE STORE IN MY_KEY"}

iex> Kaur.Environment.read(:my_app, :my_key2, [:secret])
{:ok, "MY VALUE"}

iex> Kaur.Environment.read(:my_app, :something_else)
{:error, :no_value}