Configuration validation using pydantic
We should validate the configuration files using pydantic, and generate documentation with pydantic-autodoc.
As a bonus, we could implement a command line option that would generate a configuration files with the default values + the environment values.
https://docs.pydantic.dev/latest/usage/settings/
Questions on Flask+pydantic_settings integration:
- How to put a
BaseSettings
as aapp.conf
? The object interface is very convenient for development, Flask excepts a dict here. - A custom
BaseSettings
won't necessarily cary all the Flask configuration options, somodel_config = SettingsConfigDict(extra='allow')
might be needed.
Todo
-
write configuration using pydantic -
parse configuration with pydantic at startup -
find a way to keep reading secrets from files -
implement, test and document configuration using environment variables -
refactor the existing configuration checks (for example the code that checks that the LDAP connection is valid etc.) -
write a command that generates a configuration file (for example, exports a toml file from the current configuration, including the comments) -
refactor Canaille so it uses pydantic object for Canaille specific configuration (maybe in another MR)
Edited by Éloi Rivard