pillar.config 🔗
ConfigLoader 🔗
ConfigLoader(
default_config: Optional[Dict[str, Any]] = None,
default_parsers: Optional[
Dict[str, ConfigParser]
] = None,
)
Bases: LoggingMixin
Load and merge multiple config files from various locations.
Attributes:
Name | Type | Description |
---|---|---|
logger |
Logger
|
|
merger |
Merger
|
deepmerge merger |
parsers |
Dict[str, ConfigParser]
|
loaded parses |
config |
Dict[str, Any]
|
computed config |
load_stack |
Dict[str, Dict[str, Any]]
|
loaded files and their respective config before merging. Because dictionaries are ordered this will also be in order of loading. The only only exception is if the same file is loaded multiple times (don't do that). |
load_errors |
Dict[str, Dict[str, Any]]
|
errors encountered when loading files. If the same file is loaded multiple times, it will only have the latest error encountered. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
default_config |
Optional[Dict[str, Any]]
|
Set initial |
None
|
default_parsers |
Optional[Dict[str, ConfigParser]]
|
Use these parsers instead of the |
None
|
critical 🔗
Log a CRITICAL message
Something is on fire. We somehow caught it but we probably need to exit now. If we keep going more things may catch on fire.
In a larger system, someone is probably going to get paged over this. An end user is definitely going to get an error message, probably not even a useful one, just a HTTP 500.
error 🔗
Log an ERROR message
Something bad has happened but we caught it. We might be able to continue, but other things might start breaking. We can probably still safely exit.
In a larger system, this will likely cause a gentle alert to be placed somewhere. An end user might receive a useful error message (like a HTTP 4xx 5xx).
get_logger
classmethod
🔗
Get a logging.Logger
for this class
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prefix |
str
|
optional prefix for the logger name |
''
|
info 🔗
Log an INFO message
Print something to the screen/logfile so we know what is happening
load_config 🔗
Load a given config path.
The loaded config will be merged into self.config
. The actual config loaded will
also be stored in self.load_stack[path]
. Any errors during loading will be stored
in self.load_errors[path]
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
Union[str, Path]
|
Path to try load from. Can include scheme (e.g. |
required |
suppress_errors |
bool
|
Prevent errors from being thrown while loading the config. This
does not affect errors being stored in |
False
|
Raises:
Type | Description |
---|---|
ValueError
|
Unsupported path scheme |
vdebug 🔗
Log a Verbose Debug (VDEBUG) message.
More than debug, less than everything.
vvdebug 🔗
Log a Very Verbose Debug (VVDEBUG) message.
When you're tired of finding the bug and want to log everything.
warning 🔗
Log a WARNING message
Something is wrong but we likely can recover or skip it without issue.
In a larger system this will likely just go to centralised logging.
ConfigParser 🔗
Base class for config loaders.
parse_content 🔗
Parse content into usable config.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content |
bytes
|
Raw content to load from |
required |
JsonParser 🔗
Bases: ConfigParser
Config parser for JSON
If orjson
is installed will use that for parsing.
It can be installed using pillar[recommended]
.
parse_content 🔗
Parse config into a usable config.