Add env variables to default config

This commit is contained in:
vrde 2016-04-26 03:24:56 +02:00
parent c3ad343e77
commit f9c609ff0d
No known key found for this signature in database
GPG Key ID: 6581C7C39B3D397D
4 changed files with 12 additions and 5 deletions

View File

@ -52,6 +52,8 @@ def run_configure(args, skip_if_exists=False):
skip_if_exists (bool): skip the function if a config file already exists
"""
config_path = args.config or bigchaindb.config_utils.CONFIG_DEFAULT_PATH
bigchaindb.config_utils.autoconfigure(filename=False, force=True)
config_file_exists = False
# if the config path is `-` then it's stdout
@ -68,7 +70,8 @@ def run_configure(args, skip_if_exists=False):
return
# Patch the default configuration with the new values
conf = copy.deepcopy(bigchaindb._config)
conf = copy.deepcopy(bigchaindb.config)
del conf['CONFIGURED']
print('Generating keypair', file=sys.stderr)
conf['keypair']['private'], conf['keypair']['public'] = \

View File

@ -91,7 +91,11 @@ def file_config(filename=None):
file at CONFIG_DEFAULT_PATH, if filename == None)
"""
logger.debug('On entry into file_config(), filename = {}'.format(filename))
if not filename:
if filename is False:
return {}
if filename is None:
filename = CONFIG_DEFAULT_PATH
logger.debug('file_config() will try to open `{}`'.format(filename))

View File

@ -73,7 +73,7 @@ setup(
]
},
install_requires=[
'rethinkdb==2.2.0.post4',
'rethinkdb==2.3.0',
'pysha3==0.3',
'pytz==2015.7',
'cryptoconditions==0.1.6',

View File

@ -186,7 +186,7 @@ def test_run_configure_when_config_does_not_exist(monkeypatch,
mock_bigchaindb_backup_config):
from bigchaindb.commands.bigchain import run_configure
monkeypatch.setattr('os.path.exists', lambda path: False)
monkeypatch.setattr('builtins.input', lambda question: '\n')
monkeypatch.setattr('builtins.input', lambda: '\n')
args = Namespace(config='foo', yes=True)
return_value = run_configure(args)
assert return_value is None
@ -202,7 +202,7 @@ def test_run_configure_when_config_does_exist(monkeypatch,
from bigchaindb.commands.bigchain import run_configure
monkeypatch.setattr('os.path.exists', lambda path: True)
monkeypatch.setattr('builtins.input', lambda question: '\n')
monkeypatch.setattr('builtins.input', lambda: '\n')
monkeypatch.setattr('bigchaindb.config_utils.write_config', mock_write_config)
args = Namespace(config='foo', yes=None)