Merge lp:~abentley/ci-director/allow-colon into lp:ci-director

Proposed by Aaron Bentley
Status: Merged
Merged at revision: 190
Proposed branch: lp:~abentley/ci-director/allow-colon
Merge into: lp:ci-director
Diff against target: 33 lines (+11/-1)
2 files modified
cidirector/cidirector.py (+1/-1)
cidirector/tests/test_cidirector.py (+10/-0)
To merge this branch: bzr merge lp:~abentley/ci-director/allow-colon
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+315383@code.launchpad.net

Commit message

Allow colons in ci-director config values.

Description of the change

Colons in ci-director config values break our scripts.

The problem is that the output of split(':') is fed into a two-value tuple, so when there is more than one ":", we get a ValueError: too many values to unpack.

This branch changes it so that we do split(':', 1). The first colon is treated as a separator, and the rest become part of the value.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cidirector/cidirector.py'
2--- cidirector/cidirector.py 2017-01-16 16:58:05 +0000
3+++ cidirector/cidirector.py 2017-01-23 15:45:52 +0000
4@@ -404,7 +404,7 @@
5 if not found_stanza and '[{}]'.format(section) == line.strip():
6 found_stanza = True
7 if found_stanza and ':' in line:
8- key, value = line.split(':')
9+ key, value = line.split(':', 1)
10 key = key.strip().lower().replace('-', '_')
11 if key in options:
12 value = value.strip().lower()
13
14=== modified file 'cidirector/tests/test_cidirector.py'
15--- cidirector/tests/test_cidirector.py 2017-01-16 16:58:05 +0000
16+++ cidirector/tests/test_cidirector.py 2017-01-23 15:45:52 +0000
17@@ -2001,6 +2001,16 @@
18 {'supported_substrates': ['foo', 'bar', 'baz']},
19 )
20
21+ def test_config_from_description_colon(self):
22+ config = ResourcefulJob.config_from_description(
23+ 'id', dedent("""\
24+ [ci-director]
25+ group-name: foo:bar
26+ """), logging.getLogger())
27+ self.assertEqual(
28+ config,
29+ {'group_name': 'foo:bar'})
30+
31 def test_get_job_from_jenkins(self):
32 server_info = make_server_info(
33 'idle', buildable=['foo'], building=['build-revision'],

Subscribers

People subscribed via source and target branches