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:
parent
03f7c4c2cb
commit
7f0b4f3001
@ -252,6 +252,10 @@ class LocalConf(object):
|
||||
if localrc:
|
||||
vg = VarGraph(localrc)
|
||||
for k, v in vg.getVars():
|
||||
# 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
|
||||
|
@ -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'))
|
||||
|
Loading…
Reference in New Issue
Block a user