Fix the bug when some value in labels has comma, it will fail.
Now using 'comma' split the labels list result in the fail when some value in labels list has comma, for example, mesos_slave_isolation= docker/runtime,filesystem/linux The patch fix the bug that some value in labels list has comma will fail. Change-Id: I1553b512e4e2efa7677efadf44e959f1601d39ad Closes-Bug: #1578498
This commit is contained in:
parent
3e025e40b8
commit
406528ec21
@ -89,7 +89,7 @@ def format_labels(lbls, parse_comma=True):
|
||||
if parse_comma:
|
||||
# expect multiple invocations of --labels but fall back
|
||||
# to either , or ; delimited if only one --labels is specified
|
||||
if len(lbls) == 1:
|
||||
if len(lbls) == 1 and lbls[0].count('=') > 1:
|
||||
lbls = lbls[0].replace(';', ',').split(',')
|
||||
|
||||
labels = {}
|
||||
|
@ -191,12 +191,12 @@ class FormatLabelsTest(test_utils.BaseTestCase):
|
||||
self.assertIn('V1', l['K1'])
|
||||
self.assertIn('V2', l['K1'])
|
||||
|
||||
def test_format_label_bad_label(self):
|
||||
def test_format_label_special_label(self):
|
||||
labels = ['K1=V1,K22.2.2.2']
|
||||
ex = self.assertRaises(exc.CommandError,
|
||||
utils.format_labels, labels)
|
||||
self.assertEqual('labels must be a list of KEY=VALUE '
|
||||
'not K22.2.2.2', str(ex))
|
||||
l = utils.format_labels(
|
||||
labels,
|
||||
parse_comma=True)
|
||||
self.assertEqual({'K1': 'V1,K22.2.2.2'}, l)
|
||||
|
||||
def test_format_multiple_bad_label(self):
|
||||
labels = ['K1=V1', 'K22.2.2.2']
|
||||
|
Loading…
Reference in New Issue
Block a user