From 699b53964e4f9dba9b529b5af0a243c732b6fd5a Mon Sep 17 00:00:00 2001 From: Oleksii Kliukin Date: Thu, 24 Mar 2016 10:48:29 +0100 Subject: [PATCH] Make sure present but empty optional sections don't cause errors. --- patroni/postgresql.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/patroni/postgresql.py b/patroni/postgresql.py index df17200d..0d1a8e44 100644 --- a/patroni/postgresql.py +++ b/patroni/postgresql.py @@ -44,17 +44,18 @@ class Postgresql(object): def __init__(self, config): self.config = config self.name = config['name'] - self.server_parameters = config.get('parameters', {}) + self.server_parameters = config.get('parameters') or {} self.scope = config['scope'] self.listen_addresses, self.port = config['listen'].split(':') self.data_dir = config['data_dir'] self.replication = config['replication'] - self.superuser = config['superuser'] - self.admin = config['admin'] - self.initdb_options = config.get('initdb', []) + self.superuser = config.get('superuser') or {} + self.admin = config.get('admin') or {} + + self.initdb_options = config.get('initdb') or [] self.pgpass = config.get('pgpass') or os.path.join(os.path.expanduser('~'), 'pgpass') - self.pg_rewind = config.get('pg_rewind', {}) - self.callback = config.get('callbacks', {}) + self.pg_rewind = config.get('pg_rewind') or {} + self.callback = config.get('callbacks') or {} self.use_slots = config.get('use_slots', True) self.schedule_load_slots = self.use_slots self.recovery_conf = os.path.join(self.data_dir, 'recovery.conf')