DO NOT USE - This is a beta package
Project description
confizzo
confizzo is a configuration management library. It is designed to contain many versions of configuration managed approaches into a single API.
Multi-file Configurations
Multifile configurations, in confizzo terms, are configurations which are partitioned into multiple files. One assumption is that when one configuration contains configuration information of another entity, that that configuration is then stored in a separate configuration file and referenced by type corresponds to filename and the name of the configuration in the file.
Specifications
Here the configuration is parsed into one or more files. When a configuration has a dependency on another object - via composition - the configuration for such objects will be stored in separate files. ALl objects of similar type - save the entry point objects, will be stored in files denoted by name the kind of class (via vase class) for which they will configure. In the 'main.yml' - the entrypoint configuration - the configurations will be
object:
type: class_type
conf: SOME CONFIGURATION DICTIONARY
_dependencies_:
- List of dependency descriptions
The list of dependency descriptions will have objects as follows
var_name: NAME OF THE VARIABLE (COMPOSED OBJECT) THIS CONFIGURATION WILL BELONG TO
name: NAME OF CONFIGURATION FROM THE CONF_TYPE LOCATION
conf_type: IDENTIFIES THE KIND OF CONFIGURATION - WHERE THEY WILL BE STORED.
The _dependencies_ section is used to
- Help populate the configuration repository
- Used to identify the references to the Class that can be dynamically injected and to reference the right configuration
The pattern aimed to be used here is to
- Create an object from it's configuration (non-injectable objects)
- From _dependencies_ find the Class that will be constructed and the name (as a passable conf value) of the key used to reference that objects configuration.
Examples
Assume that we have an application called data_mover. Then for this application, running in local mode, the configuration will be stored at .data_mover at the $HOME path.
main.yml
version: 1
system_1:
type: ClassA
conf:
param_1: something
param_2: other
_dependencies_:
- var_name: db_conn
name: dev_pg
conf_type: database
database.yaml
version: 1
dev_pg:
obj_type: PostgresDB
user: user
password: password
host: 10.0.0.7
database: root
The usage patter would be something like this: main.py
from providah.factories.package_factory import PackageFactory
from confizzo.multifile.config_manager import ConfigManager
from confizzo.multifile.parser import Parser
def main():
ConfigManager.config_root = '~/.data_mover/config.yml'
conf_key = 'ClassA'
config = Parser.get(conf_key)
obj_type = config.pop('type')
system_1 = PackageFactory.create(key=obj_type, **{'conf_key': conf_key})
system_1.run()
system_1.py
from providah.factories.package_factory import PackageFactory
from confizzo.multifile.parser import Parser
class System1:
def __init__(self, conf_key: str):
self.__config = Parser.get(conf_key)
dependencies = self.__config['_dependencies_']
conf_for_db_conn_ref = [dep for dep in dependencies if dep['var_name'] == 'db_conn']
self.__db_conn = PackageFactory.create(key=Parser.get(conf_for_db_conn_ref['type']),
**{'conf_key': conf_for_db_conn_ref['name']})
def run(self):
self.__db_conn.execute('SELECT 1')
postgres_db.py
from confizzo.multifile.parser import Parser
class PostgresDB:
def __init__(self, conf_key: str):
# Configuration contains secrets, so we don't want to expose this except when executing a query.
self.__config_name = conf_key
def execute(self, query: str) -> None:
conf = Parser.get(self.__config_name)['conf']
conn = self.__get_connection(conf)
conn.cursor.execute(query)
conn.close()
def __get_connection(self, conf: str) -> Connection:
pass
TODO
There are a number of feature that could be added
- Simpler reference of dependencies from configuration using library and avoiding bespoke solution and
- Additional filtering when referencing configurations
- Additional configuration that ties to providah package (maybe)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file confizzo-0.1.1.0.tar.gz
.
File metadata
- Download URL: confizzo-0.1.1.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ae7612bf6f29fd101c6d2cf76e302fee3b6df981742cb4af58deb65643f73d4 |
|
MD5 | ac77e6d9b7cdab2844c05b21b7488b20 |
|
BLAKE2b-256 | c3256bac683101b30a012195854e1b0b2a2b6c10472f959982fe70720f7f1175 |