confmgr
confmgr brings interesting features that are not available in libs. While focusing on ease of use, it brings features that no longer need to be part of your app such as:
-
type conversion (variables from ENV are always strings,
confmgrconverts them for you) -
mandatory values: If you miss a value,
confmgrwill tell you before your app explodes… -
default values:
confmrghandles default values for you -
regular expressions:
confmgrallows you defining a regexp that will allow checking the validity of the loaded config -
masked variables: handy for your secrets, read below
After getting your config object with GetConfig(), you can simple use it with config['MYAPP_MYMODULE_VAR1'] or use some of the helper methods attached to your config.
confmgr brings a set of handy methods such as Print() that will display the content of your config while ensuring that your secrets do NOT show up in any log or output.
Printing your config may use colors or not. Here is an example with color coming from running config.Print():
===> TS_SAMPLE_MODULE_01 ENV:
✅ PARAM1: some param1
value: 12
✅ PARAM2: some param2
value: 44
✅ SECRET: some secret
value: ***** <---- Notice how this value has been masked
✅ REGEXP: some regexp
regexp: ^\d{2}_\d{2}
value: 68_77
✅ MANDAT_WITH_DEF: some optional param
value: 42
❌ MANDAT_NO_DEF: some optional param <----- It looks like we forgot to pass a value
value: undefined
|
Note
|
If you are using a custom logger, you may also pass it to the Print() method so the output gets nicely integrated to your logs while NOT revealing any of your secrets.
|
You can read more about it at https://gitlab.com/chevdor/confmgr