From d39d297d92e3703184709198eb3576c5575a5c16 Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Thu, 12 Nov 2015 12:07:36 +0100 Subject: [PATCH] blacklist some options for initdb instead of having big whitelist --- patroni/postgresql.py | 7 ++----- tests/test_postgresql.py | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/patroni/postgresql.py b/patroni/postgresql.py index e1e96fb2..9b51da2c 100644 --- a/patroni/postgresql.py +++ b/patroni/postgresql.py @@ -169,11 +169,8 @@ class Postgresql: @staticmethod def initdb_allowed_option(name): - allowed_options = set(['auth', 'auth-host', 'auth-local', 'encoding', 'data-checksums', - 'locale', 'lc-collate', 'lc-ctype', 'lc-messages', 'lc-monetary', - 'lc-numeric', 'lc-time', 'text-search-config', 'xlogdir', 'debug', 'noclean']) - if name not in allowed_options: - raise Exception('{} option for initdb is unknown or not allowed'.format(name)) + if name in ['pgdata', 'nosync', 'pwfile', 'sync-only']: + raise Exception('{} option for initdb is not allowed'.format(name)) return True def get_initdb_options(self): diff --git a/tests/test_postgresql.py b/tests/test_postgresql.py index 6f0e807a..3e8caf47 100644 --- a/tests/test_postgresql.py +++ b/tests/test_postgresql.py @@ -190,7 +190,7 @@ class TestPostgresql(unittest.TestCase): def test_get_initdb_options(self): self.p.initdb_options = [{'encoding': 'UTF8'}, 'data-checksums'] self.assertEquals(self.p.get_initdb_options(), ['--encoding=UTF8', '--data-checksums']) - self.p.initdb_options = [{'foo': 'bar'}] + self.p.initdb_options = [{'pgdata': 'bar'}] self.assertRaises(Exception, self.p.get_initdb_options) self.p.initdb_options = [{'foo': 'bar', 1: 2}] self.assertRaises(Exception, self.p.get_initdb_options)