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
| ... | ... |
@@ -252,7 +252,11 @@ class LocalConf(object): |
| 252 | 252 |
if localrc: |
| 253 | 253 |
vg = VarGraph(localrc) |
| 254 | 254 |
for k, v in vg.getVars(): |
| 255 |
- self.localrc.append('{}="{}"'.format(k, v))
|
|
| 255 |
+ # Avoid double quoting |
|
| 256 |
+ if len(v) and v[0]=='"': |
|
| 257 |
+ self.localrc.append('{}={}'.format(k, v))
|
|
| 258 |
+ else: |
|
| 259 |
+ self.localrc.append('{}="{}"'.format(k, v))
|
|
| 256 | 260 |
if k == 'LIBS_FROM_GIT': |
| 257 | 261 |
lfg = True |
| 258 | 262 |
elif k == 'TEMPEST_PLUGINS': |
| ... | ... |
@@ -187,6 +187,24 @@ class TestDevstackLocalConf(unittest.TestCase): |
| 187 | 187 |
lfg = line.strip().split('=')[1]
|
| 188 | 188 |
self.assertEqual('"oslo.db"', lfg)
|
| 189 | 189 |
|
| 190 |
+ def test_avoid_double_quote(self): |
|
| 191 |
+ "Test that there a no duplicated quotes" |
|
| 192 |
+ localrc = {'TESTVAR': '"quoted value"'}
|
|
| 193 |
+ p = dict(localrc=localrc, |
|
| 194 |
+ base_services=[], |
|
| 195 |
+ base_dir='./test', |
|
| 196 |
+ path=os.path.join(self.tmpdir, 'test.local.conf'), |
|
| 197 |
+ projects={})
|
|
| 198 |
+ lc = self._init_localconf(p) |
|
| 199 |
+ lc.write(p['path']) |
|
| 200 |
+ |
|
| 201 |
+ testvar = None |
|
| 202 |
+ with open(p['path']) as f: |
|
| 203 |
+ for line in f: |
|
| 204 |
+ if line.startswith('TESTVAR'):
|
|
| 205 |
+ testvar = line.strip().split('=')[1]
|
|
| 206 |
+ self.assertEqual('"quoted value"', testvar)
|
|
| 207 |
+ |
|
| 190 | 208 |
def test_plugin_circular_deps(self): |
| 191 | 209 |
"Test that plugins with circular dependencies fail" |
| 192 | 210 |
os.makedirs(os.path.join(self.tmpdir, 'foo-plugin', 'devstack')) |