Merge ~chris.sanders/juju-lint/+git/csanders:1814135 into juju-lint:master

Proposed by Chris Sanders
Status: Merged
Approved by: Chris Sanders
Approved revision: d4da2462a684e54271efeb0dc2a748a2508eb5a7
Merged at revision: dbd758bdbd6ac6fcf1b409a231c2fa7c9eb898d7
Proposed branch: ~chris.sanders/juju-lint/+git/csanders:1814135
Merge into: juju-lint:master
Diff against target: 44 lines (+12/-2)
2 files modified
jujulint.py (+8/-2)
tests/test_jujulint.py (+4/-0)
Reviewer Review Type Date Requested Status
Joel Sing (community) +1 Approve
Chris Sanders (community) Needs Resubmitting
Review via email: mp+362624@code.launchpad.net

Commit message

Handle hyphen in charm user names

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Joel Sing (jsing) :
review: Needs Fixing
Revision history for this message
Chris Sanders (chris.sanders) wrote :

Updates applied, resubmitting

review: Needs Resubmitting
Revision history for this message
Joel Sing (jsing) wrote :

LGTM

review: Approve (+1)
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision dbd758bdbd6ac6fcf1b409a231c2fa7c9eb898d7

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/jujulint.py b/jujulint.py
2index 5aae9ff..a3d1e0f 100755
3--- a/jujulint.py
4+++ b/jujulint.py
5@@ -36,6 +36,10 @@ import attr
6 # - info mode, e.g. num of machines, version (e.g. look at ceph), architecture
7
8
9+class InvalidCharmNameError(Exception):
10+ pass
11+
12+
13 @attrs
14 class ModelInfo(object):
15 # Info obtained from juju status data
16@@ -265,8 +269,10 @@ def results(model):
17 def map_charms(applications, model):
18 for app in applications:
19 charm = applications[app]["charm"]
20- match = re.search(r'^(\w+:)?(~\w+/)?(\w+/)?([a-zA-Z0-9-]+?)(-\d+)?$', charm)
21- charm = match.group(4)
22+ match = re.match(r'^(?:\w+:)?(?:~[\w-]+/)?(?:\w+/)?([a-zA-Z0-9-]+?)(?:-\d+)?$', charm)
23+ if not match:
24+ raise InvalidCharmNameError("charm name '{}' is invalid".format(charm))
25+ charm = match.group(1)
26 model.charms.add(charm)
27 model.app_to_charm[app] = charm
28
29diff --git a/tests/test_jujulint.py b/tests/test_jujulint.py
30index 187adc5..acf5cdc 100644
31--- a/tests/test_jujulint.py
32+++ b/tests/test_jujulint.py
33@@ -23,7 +23,11 @@ class TestJujuLint(unittest.TestCase):
34 'test-app-3': {'charm': "cs:TEST-CHARM12-123"},
35 'test-app-4': {'charm': "local:SERIES/TEST-CHARM12"},
36 'test-app-5': {'charm': "local:TEST-CHARM12"},
37+ 'test-app-6': {'charm': "cs:~TEST-CHARMERS/TEST-CHARM12-123"},
38 }
39 jujulint.map_charms(applications, model)
40 for charm in model.charms:
41 self.assertEqual("TEST-CHARM12", charm)
42+ applications = {'test-app1': {'charm': "cs:invalid-charm$"}, }
43+ with self.assertRaises(jujulint.InvalidCharmNameError):
44+ jujulint.map_charms(applications, model)

Subscribers

People subscribed via source and target branches