summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrebs <drebs@riseup.net>2017-08-30 12:45:37 -0300
committerdrebs <drebs@riseup.net>2017-08-31 10:48:17 -0300
commit5c2a612aec7919c4935d3dcdf666642beaa74379 (patch)
tree0217d1aed4f3c1c2974a160942e8be0291123771
parenta5c77dcbc875d001f2a0ffba3249537f58556897 (diff)
[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.
-rw-r--r--src/leap/soledad/server/_config.py7
1 files 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]