add layered configuration
Closes #7 (closed) #1 (closed)
This MR adds a simple function called lbnightly_settings()
returning layered configuration store, based on configurator
.
For now, we have three layers:
- hardcoded defaults
- system level
secrets.yaml
expected to be found in$PRIVATE_DIR
or~/private/
(as currently defined in https://gitlab.cern.ch/lhcb-core/nightly-builds/lb-nightly-deployment) - user level yaml file provided as an argument to the
lbnightly_settings()
We could extend the list with e.g. environment variables.
Example of usage:
>>> from lb.nightly.configuration import lbnightly_settings
>>> settings = lbnightly_settings()
>>> settings.couchdb.url
'http://localhost:8080/couchdb/nightly-builds'
>>> settings['couchdb']['url']
'http://localhost:8080/couchdb/nightly-builds'
>>> settings.data
{'couchdb': {'url': 'http://localhost:8080/couchdb/nightly-builds'}, 'rabbitmq': {'url': 'amqp://guest:guest@localhost:5672'}, 'mysql': {'url': 'db+mysql://'}, 'artifacts': {'uri': 'http://localhost:8081/repository/nightly_builds_artifacts/'}, 'logs': {'uri': 'http://localhost:8081/repository/nightly_builds_logs/'}, 'elasticsearch': {'uri': 'http://localhost:9200'}}
I looked also at much more powerful libraries like dynaconf, hydra or environ-config, but I'm not sure if that's needed for our use case.
Edited by Maciej Pawel Szymanski