mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-31 08:39:34 +00:00
blacklist some options for initdb instead of having big whitelist
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user