Merge lp:~johnsca/juju-deployer/series-fix into lp:juju-deployer

Proposed by Cory Johns
Status: Merged
Merged at revision: 197
Proposed branch: lp:~johnsca/juju-deployer/series-fix
Merge into: lp:juju-deployer
Diff against target: 77 lines (+34/-1)
2 files modified
deployer/charm.py (+22/-1)
deployer/tests/test_charm.py (+12/-0)
To merge this branch: bzr merge lp:~johnsca/juju-deployer/series-fix
Reviewer Review Type Date Requested Status
Konstantinos Tsakalozos (community) Approve
Kevin W Monroe (community) Approve
juju-deployers Pending
Review via email: mp+309143@code.launchpad.net

Description of the change

When a bundle contains charm URLs with the series embedded that don't match the bundle-level series, deployer didn't honor it and tried to use the bundle series instead.

To post a comment you must log in.
Revision history for this message
Kevin W Monroe (kwmonroe) wrote :

LGTM, +1

review: Approve
Revision history for this message
Konstantinos Tsakalozos (kos.tsakalozos) wrote :

LGTM +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'deployer/charm.py'
2--- deployer/charm.py 2016-09-14 02:25:35 +0000
3+++ deployer/charm.py 2016-10-24 16:54:17 +0000
4@@ -71,6 +71,22 @@
5 name = data.get('charm', name)
6 if name.startswith('cs:'):
7 store_url = name
8+ if 'series' not in data:
9+ series = deploy_series
10+ if ':' in store_url and '/' in store_url:
11+ # attempt to extract series from charm URL
12+ url_parts = store_url.split(':', 1)[1].split('/')
13+ # remove namespace
14+ if url_parts[0].startswith('~'):
15+ url_parts = url_parts[1:]
16+ elif url_parts[0] == 'u':
17+ url_parts = url_parts[2:]
18+ # check for series in URL
19+ if len(url_parts) > 1:
20+ # URL includes series
21+ series = url_parts[0]
22+ # update data dict with series
23+ data = dict(data, series=series)
24 elif name.startswith('local:'):
25 # Support vcs charms specifying their
26 parts = name[len('local:'):].split('/')
27@@ -81,6 +97,7 @@
28 name = parts.pop()
29 else:
30 series = deploy_series
31+ data = dict(data, series=deploy_series)
32 charm_path = path_join(repo_path, series, name)
33 elif os.path.isabs(name):
34 # charm points to an absolute local path
35@@ -90,6 +107,7 @@
36 charm_path = path_join(repo_path, series, name)
37 else:
38 charm_path = path_join(repo_path, deploy_series, name)
39+ data = dict(data, series=deploy_series)
40
41 if not store_url:
42 store_url = data.get('charm_url', None)
43@@ -185,7 +203,10 @@
44 def series(self):
45 if self.data.get('series'):
46 return self.data.get('series')
47- metadata_series = self.metadata.get('series')
48+ try:
49+ metadata_series = self.metadata.get('series')
50+ except RuntimeError:
51+ metadata_series = None
52 if metadata_series:
53 return metadata_series[0]
54 if self.series_path:
55
56=== modified file 'deployer/tests/test_charm.py'
57--- deployer/tests/test_charm.py 2016-05-13 14:16:48 +0000
58+++ deployer/tests/test_charm.py 2016-10-24 16:54:17 +0000
59@@ -21,6 +21,18 @@
60 def test_repo_path(self):
61 self.assertIsNone(self.charm.repo_path)
62
63+ def test_series(self):
64+ def _c(url, deploy_series, data_series):
65+ return Charm.from_service(url, None, deploy_series, {
66+ 'series': data_series,
67+ } if data_series else {}).series
68+ self.assertEqual('trusty', _c('cs:trusty/ubuntu', None, None))
69+ self.assertEqual('trusty', _c('cs:trusty/ubuntu', 'xenial', None))
70+ self.assertEqual('xenial', _c('cs:trusty/ubuntu', 'trusty', 'xenial'))
71+ self.assertEqual('xenial', _c('cs:ubuntu', 'trusty', 'xenial'))
72+ self.assertEqual('trusty', _c('cs:ubuntu', 'trusty', None))
73+ self.assertIsNone(_c('cs:ubuntu', None, None))
74+
75
76 class AbsolutePathCharmTest(Base):
77 def setUp(self):

Subscribers

People subscribed via source and target branches