From 5c2a612aec7919c4935d3dcdf666642beaa74379 Mon Sep 17 00:00:00 2001 From: drebs Date: Wed, 30 Aug 2017 12:45:37 -0300 Subject: [feat] get config file name from environment For tests, we may want to configure the server with non-default options, and the easiest way to do this is by creating a configuration file in a temporary directory and passing the file name by means of an environment variable. This commit changes the server config file loading scheme to account for a variable called SOLEDAD_SERVER_CONFIG_FILE. If that variable is set, the configuration is read from the file pointed by it. Otherwise, /etc/soledad/soledad-server.conf is used. --- src/leap/soledad/server/_config.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/leap/soledad/server/_config.py b/src/leap/soledad/server/_config.py index e89e70d6..147612fb 100644 --- a/src/leap/soledad/server/_config.py +++ b/src/leap/soledad/server/_config.py @@ -17,11 +17,12 @@ import configparser +import os __all__ = ['get_config'] - +DEFAULT_CONFIG_FILE = '/etc/soledad/soledad-server.conf' CONFIG_DEFAULTS = { 'soledad-server': { 'couch_url': 'http://localhost:5984', @@ -46,7 +47,9 @@ _config = None def get_config(section='soledad-server'): global _config if not _config: - _config = _load_config('/etc/soledad/soledad-server.conf') + fname = os.environ.get( + 'SOLEDAD_SERVER_CONFIG_FILE', DEFAULT_CONFIG_FILE) + _config = _load_config(fname) return _config[section] -- cgit v1.2.3