Merge ~sbparke/juju-lint/+git/juju-lint-1:bug/1950980 into juju-lint:master

Proposed by Steven Parker
Status: Merged
Approved by: James Troup
Approved revision: c3a4a4acdba5927e5ef53c2fc5a9a2799279e126
Merged at revision: bded6f99e66f2ddcab54767f8184bab727c6d415
Proposed branch: ~sbparke/juju-lint/+git/juju-lint-1:bug/1950980
Merge into: juju-lint:master
Diff against target: 25 lines (+2/-1)
2 files modified
jujulint/util.py (+1/-1)
tests/test_jujulint.py (+1/-0)
Reviewer Review Type Date Requested Status
Juju Lint maintainers patch applied Pending
Review via email: mp+411887@code.launchpad.net

Commit message

Modified regex to handle charm hub applications and updated test

Description of the change

Modification to charm name validation to handle charm hub format
  ch:amd64/bionic/TEST-CHARM12-123

Currently regex only handles blah/charm-name not blah/blah/blah/charm-name

Changed ? to * to handle this in regex

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
Steven Parker (sbparke) wrote :
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision bded6f99e66f2ddcab54767f8184bab727c6d415

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/jujulint/util.py b/jujulint/util.py
2index fc45ee6..283fa4b 100644
3--- a/jujulint/util.py
4+++ b/jujulint/util.py
5@@ -77,7 +77,7 @@ def is_metal(machine, machine_data):
6 def extract_charm_name(charm):
7 """Extract the charm name using regex."""
8 match = re.match(
9- r"^(?:\w+:)?(?:~[\w\.-]+/)?(?:\w+/)?([a-zA-Z0-9-]+?)(?:-\d+)?$", charm
10+ r"^(?:\w+:)?(?:~[\w\.-]+/)?(?:\w+/)*([a-zA-Z0-9-]+?)(?:-\d+)?$", charm
11 )
12 if not match:
13 raise InvalidCharmNameError("charm name '{}' is invalid".format(charm))
14diff --git a/tests/test_jujulint.py b/tests/test_jujulint.py
15index d865c63..d246dfc 100644
16--- a/tests/test_jujulint.py
17+++ b/tests/test_jujulint.py
18@@ -104,6 +104,7 @@ class TestLinter:
19 "test-app-4": {"charm": "local:SERIES/TEST-CHARM12"},
20 "test-app-5": {"charm": "local:TEST-CHARM12"},
21 "test-app-6": {"charm": "cs:~TEST-CHARMERS/TEST-CHARM12-123"},
22+ "test-app-7": {"charm": "ch:amd64/bionic/TEST-CHARM12-123"}
23 }
24 linter.map_charms(applications)
25 for charm in linter.model.charms:

Subscribers

People subscribed via source and target branches