refactor password assignment logic
This commit is contained in:
parent
a9386b7a87
commit
b7423c488e
2 changed files with 5 additions and 2 deletions
|
@ -72,7 +72,7 @@ def restore_single_database(
|
|||
): # pragma: no cover
|
||||
'''
|
||||
Given (among other things) an archive name, a database hook name, the hostname,
|
||||
port, username and password as connection params, and a configured database
|
||||
port, username and password as connection params, and a configured database
|
||||
configuration dict, restore that database from the archive.
|
||||
'''
|
||||
logger.info(
|
||||
|
|
|
@ -30,7 +30,10 @@ def make_extra_environment(database, restore_connection_params=None):
|
|||
extra = dict()
|
||||
|
||||
try:
|
||||
extra['PGPASSWORD'] = restore_connection_params.get('password') or database['restore_password'] or database['password']
|
||||
if restore_connection_params:
|
||||
extra['PGPASSWORD'] = restore_connection_params.get('password') or database.get('restore_password', database['password'])
|
||||
else:
|
||||
extra['PGPASSWORD'] = database['password']
|
||||
except (AttributeError, KeyError):
|
||||
pass
|
||||
|
||||
|
|
Loading…
Reference in a new issue