Confispex (confispex v0.5.0)
A tool which allows to define specs for runtime configuration, cast values according to specified types and inspect them.
Link to this section Summary
Functions
Returns true
if all required variables in specified group were invoked using get/1
.
Returns true
if any required variable in specified group was invoked using get/1
.
Get a value from store by specified variable name (key) and cast it according to schema.
Merge new store with the existing one overriding existing keys.
Print report with variables usage to STDOUT.
Set context.
Set store unless it is already set.
Set schema.
Link to this section Functions
all_required_touched?(group_name)
Specs
Returns true
if all required variables in specified group were invoked using get/1
.
any_required_touched?(group_name)
Specs
Returns true
if any required variable in specified group was invoked using get/1
.
get(variable_name)
Specs
Get a value from store by specified variable name (key) and cast it according to schema.
Example
config :my_app, MyApp.Repo, url: Confispex.get("DATABASE_URL")
In case of any error during casting nil
is returned, errors are saved and can be
retrieved later using report/1
function.
merge_store(new_store)
Specs
merge_store(map()) :: :ok
Merge new store with the existing one overriding existing keys.
Useful when updating config in runtime.
Example
Confispex.merge_store(Jason.decode!(File.read!("config.json")))
report(mode)
Specs
report(:detailed | :brief) :: :ok
Print report with variables usage to STDOUT.
The difference between :detailed
and :brief
modes is that :brief
doesn't print values of the store.
Use :brief
if you don't want to show sensitive data.
set_context(context)
Specs
set_context(map()) :: :ok
Set context.
Most likely you'll want to setup env
and target
:
Example
Confispex.set_context(%{env: config_env(), target: config_target()})
set_new_store(store)
Specs
set_new_store(map()) :: :ok
Set store unless it is already set.
Example
Confispex.set_new_store(System.get_env())
set_schema(schema)
Specs
set_schema(module()) :: :ok
Set schema.