Package: confizzo
confizzoconfizzo is a configuration management library. It is designed to contain many versions of configuration managed approaches into a single API.Multi-file ConfigurationsMultifile 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.SpecificationsHere 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 beobject:type:class_typeconf:SOME CONFIGURATION DICTIONARY_dependencies_:-List of dependency descriptionsThe list of dependency descriptions will have objects as followsvar_name:NAME OF THE VARIABLE (COMPOSED OBJECT) THIS CONFIGURATION WILL BELONG TOname:NAME OF CONFIGURATION FROM THE CONF_TYPE LOCATIONconf_type:IDENTIFIES THE KIND OF CONFIGURATION - WHERE THEY WILL BE STORED.The _dependencies_ section is used toHelp populate the configuration repositoryUsed to identify the references to the Class that can be dynamically injected and to reference the right configurationThe pattern aimed to be used here is toCreate 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.ExamplesAssume 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.ymlversion:1system_1:type:ClassAconf:param_1:somethingparam_2:other_dependencies_:-var_name:db_connname:dev_pgconf_type:databasedatabase.yamlversion:1dev_pg:obj_type:PostgresDBuser:userpassword:passwordhost:10.0.0.7database:rootThe usage patter would be something like this:
main.pyfromprovidah.factories.package_factoryimportPackageFactoryfromconfizzo.multifile.config_managerimportConfigManagerfromconfizzo.multifile.parserimportParserdefmain():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.pyfromprovidah.factories.package_factoryimportPackageFactoryfromconfizzo.multifile.parserimportParserclassSystem1:def__init__(self,conf_key:str):self.__config=Parser.get(conf_key)dependencies=self.__config['_dependencies_']conf_for_db_conn_ref=[depfordepindependenciesifdep['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']})defrun(self):self.__db_conn.execute('SELECT 1')postgres_db.pyfromconfizzo.multifile.parserimportParserclassPostgresDB: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_keydefexecute(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:passTODOThere are a number of feature that could be addedSimpler reference of dependencies from configuration using library and avoiding bespoke solution andAdditional filtering when referencing configurationsAdditional configuration that ties to providah package (maybe)