ConfigHelper (config_helper v1.0.0)

Helper functions used in config/runtime.exs

Summary

Functions

Get value from environment variable, converting it to the given type if needed.

Make a test database URL by appending _test_<partition> to the path of the given URI

Remove the sslmode query parameter from a URI

Types

Link to this type

config_type()

@type config_type() :: :str | :int | :bool | :json | :atom

Functions

Link to this function

get_env(var, default \\ :no_default, type \\ :str)

@spec get_env(String.t(), :no_default | any(), config_type()) :: any()

Get value from environment variable, converting it to the given type if needed.

If no default value is given, or :no_default is given as the default, an error is raised if the variable is not set.

Link to this function

make_test_database_url(database_url, mix_test_partition)

@spec make_test_database_url(String.t() | URI.t(), String.t()) :: String.t()

Make a test database URL by appending _test_<partition> to the path of the given URI

Link to this function

remove_sslmode_from_uri(uri)

@spec remove_sslmode_from_uri(String.t() | URI.t()) :: String.t()

Remove the sslmode query parameter from a URI

This is particularly needed to deploy a Commanded app to Fly.io when using the commanded/event_store library, because Fly.io automatically addes the sslmode param and the event store library does not support it (raises an ArgumentError if it is present.)

See: https://github.com/commanded/eventstore/issues/265