Configuration Helpers
Module: ppc_robot_lib.utils.config
- convert_to_bool(value)[source]
Convert value to a boolean.
Following strings are considered
True
:1
yes
true
y
All comparisons are case in-sensitive. Any other strings are considered
False
.Other datatypes are converted using bool(value).
None
will be converted toFalse
.
- env(name, default=None)[source]
Get a value of environment variable. Multiple lookups are performed, and the value can be loaded from files. If you pass
<NAME>
, the following lookups might be performed:<NAME>
- if this env is set, its value is used directly.<NAME>_FILE
- if this env is set, contents of the file given in the value will be loaded as value.<NAME>_SECRET
- if this env is set to<value>
, contents of the file at/run/secrets/<value>
will be loaded as value.
The lookups are performed in the order as listed, and the first value found will be used.
If no variable is set, default value will be used.
- has_env(name)[source]
Checks if the environment variable is set, or if any of the following variables is set:
<NAME>
<NAME>_FILE
<NAME>_SECRET
- secrets_dir = '/run/secrets'
Directory with secrets.