Fix double quoting issue when writing localconf

When [0] introduced quoting all arguments, it broke existing consumers
that already quote their value themselves. Fix this by avoiding to add
additional quotes to the value when it already starts with a double
quote.

[0] https://review.openstack.org/636078

Change-Id: I92146e04731efc6dcc632ae6c3a7c374e783cdba
Closes-Bug: 1822453
This commit is contained in:
Jens Harbott 2019-04-01 11:43:28 +00:00
parent 03f7c4c2cb
commit 7f0b4f3001
2 changed files with 23 additions and 1 deletions

View File

@ -252,7 +252,11 @@ class LocalConf(object):
if localrc:
vg = VarGraph(localrc)
for k, v in vg.getVars():
self.localrc.append('{}="{}"'.format(k, v))
# Avoid double quoting
if len(v) and v[0]=='"':
self.localrc.append('{}={}'.format(k, v))
else:
self.localrc.append('{}="{}"'.format(k, v))
if k == 'LIBS_FROM_GIT':
lfg = True
elif k == 'TEMPEST_PLUGINS':

View File

@ -187,6 +187,24 @@ class TestDevstackLocalConf(unittest.TestCase):
lfg = line.strip().split('=')[1]
self.assertEqual('"oslo.db"', lfg)
def test_avoid_double_quote(self):
"Test that there a no duplicated quotes"
localrc = {'TESTVAR': '"quoted value"'}
p = dict(localrc=localrc,
base_services=[],
base_dir='./test',
path=os.path.join(self.tmpdir, 'test.local.conf'),
projects={})
lc = self._init_localconf(p)
lc.write(p['path'])
testvar = None
with open(p['path']) as f:
for line in f:
if line.startswith('TESTVAR'):
testvar = line.strip().split('=')[1]
self.assertEqual('"quoted value"', testvar)
def test_plugin_circular_deps(self):
"Test that plugins with circular dependencies fail"
os.makedirs(os.path.join(self.tmpdir, 'foo-plugin', 'devstack'))