Helpers for applications built with Malla.
validate_app!/2validates an application's environment against aNimbleOptionsschema (only when the application depends on:nimble_options).keyword_merge/2andmap_merge/2are the deep merges that Malla uses for service configuration.redact/1,redact_args/2andsecret_name?/1hide secrets in terms before they are logged.
The other functions of this module are used by Malla itself and are not part of its public API.
Summary
Functions
Deep merge of two keyword lists: when both values of a key are keyword lists
they are merged, any other value of update (maps and plain lists included)
replaces the one in base.
Deep merge of two maps: nested maps are merged, any other value of update
replaces the one in base.
Hides the values of secret-looking keys (password, secret, token,
credential, api_key, hmac_key, enc_key, …) anywhere inside maps, keyword lists, lists
and tuples, and the password of any URL (ecto://user:pass@host), so
the term can be logged. Structs are kept as they are.
The arguments of a call fun, ready to be logged: all of them hidden when
the name of the function says it handles a secret (set_password,
check_password, login, verify_token, …), since the secret is
then a positional argument with no key to recognise it by;
redact/1 otherwise.
Whether a key or function name looks like it holds a secret.
Validates the environment of application app against a NimbleOptions
schema and writes the validated values back (defaults included), so the
rest of the application reads them with Application.get_env/3.
Functions
Deep merge of two keyword lists: when both values of a key are keyword lists
they are merged, any other value of update (maps and plain lists included)
replaces the one in base.
Deep merge of two maps: nested maps are merged, any other value of update
replaces the one in base.
Hides the values of secret-looking keys (password, secret, token,
credential, api_key, hmac_key, enc_key, …) anywhere inside maps, keyword lists, lists
and tuples, and the password of any URL (ecto://user:pass@host), so
the term can be logged. Structs are kept as they are.
The arguments of a call fun, ready to be logged: all of them hidden when
the name of the function says it handles a secret (set_password,
check_password, login, verify_token, …), since the secret is
then a positional argument with no key to recognise it by;
redact/1 otherwise.
Whether a key or function name looks like it holds a secret.
@spec validate_app!(NimbleOptions.schema() | NimbleOptions.t(), atom()) :: :ok
Validates the environment of application app against a NimbleOptions
schema and writes the validated values back (defaults included), so the
rest of the application reads them with Application.get_env/3.
Raises if the configuration is not valid. Meant for Application.start/2.
Available only when the application depends on :nimble_options, an optional
dependency of Malla.