Skip to content

v2.0.0 - extensibility

Compare
Choose a tag to compare
@wryfi wryfi released this 12 Apr 02:27
· 26 commits to develop since this release
f27029f

Extensible Configuration Providers

With the v2.0.0 release, cfitall moves to extensible configuration providers. Following a simple interface, anyone can now hook their own configuration provider into cfitall and benefit from all of its other features.

The included EnvironmentProvider and FilesystemProvider are reference implementations that replicate existing functionality from the 1.0 series. They implement ConfigProviderBase, which is the base base class to implement if you want to write a Provider.

Providers are managed by a ProviderManager, which is responsible for registering and deregistering providers, and controls the order in which provider configurations are merged.

The provider abstraction provides an important layer of extensibility for adding new configuration sources like etcd, consul, and more to cfitall in the future, even as separate packages.

Environment Variable Parsing

Environment variable parsing (now handled by the EnvironmentProvider) has changed somewhat in the v2 release:

  • Values must now be enclosed in square brackets to be interpreted as lists, e.g. export APP__THINGS="[first, second, third]" for cf.get('things') to return ['first', 'second', 'third'].
  • Nesting of commas is not directly supported. This will not work out of the box: export APP__PEOPLE="['doe, john', 'deer, jane']". However, you can experiment with the value_separator, which is treated as a regex, to potentially solve for such advanced use cases.

Documentation

The documentation from the README has been removed to the docs/ directory and supplemented considerably. These docs are now built with Sphinx and hosted on Read The Docs.

Quality & Testing

  • type hints were added throughout the source for v2
  • all mypy tests are passing
  • 53 unit tests (roughly 96% test coverage) are passing

Minimum Python Version

  • Python 3.8 is the minimum supported version for v2.