Merge ~sombrafam/ua-reviewkit:fix-regex-parsing into ua-reviewkit:master

Proposed by Erlon R. Cruz
Status: Merged
Merged at revision: c889906f9265c86b943df88627e6cdab65fadbe8
Proposed branch: ~sombrafam/ua-reviewkit:fix-regex-parsing
Merge into: ua-reviewkit:master
Diff against target: 69 lines (+23/-7)
2 files modified
juju/example-pass-bundle.yaml (+17/-2)
juju/ua-bundle-check.py (+6/-5)
Reviewer Review Type Date Requested Status
Edward Hope-Morley Needs Fixing
Jorge Niedbalski (community) Needs Information
Review via email: mp+407787@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jorge Niedbalski (niedbalski) wrote :

can you can you put an example of the regex you want to cover?

review: Needs Information
Revision history for this message
Edward Hope-Morley (hopem) wrote :

If you could add an example that matches that regex to https://git.launchpad.net/ua-reviewkit/tree/juju/example-pass-bundle.yaml that's be great.

review: Needs Fixing
Revision history for this message
Erlon R. Cruz (sombrafam) wrote :

Done, also added 2 more edge cases to the regex.

Revision history for this message
Edward Hope-Morley (hopem) wrote :

Looks good, im getting pep8 errors though:

$ pep8 juju/ua-bundle-check.py
juju/ua-bundle-check.py:221:26: E231 missing whitespace after ','
juju/ua-bundle-check.py:221:36: E231 missing whitespace after ','
juju/ua-bundle-check.py:570:26: E231 missing whitespace after ','
juju/ua-bundle-check.py:570:36: E231 missing whitespace after ','

Can you fix those?

Revision history for this message
Erlon R. Cruz (sombrafam) wrote :

Done

Revision history for this message
Erlon R. Cruz (sombrafam) wrote :

> Done

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/juju/example-pass-bundle.yaml b/juju/example-pass-bundle.yaml
2index e1394a4..d9a02e7 100644
3--- a/juju/example-pass-bundle.yaml
4+++ b/juju/example-pass-bundle.yaml
5@@ -8,11 +8,26 @@ applications:
6 innodb-buffer-pool-size: 6G
7 nova-compute:
8 charm: cs:~openstack-charmers-next/nova-compute-492
9- num_units: 1
10+ num_units: 1
11 options:
12- cpu-model: Skylake-Server-IBRS
13+ cpu-model: Skylake-Server-IBRS
14 rabbitmq-server:
15 charm: cs:~openstack-charmers-next/rabbitmq-server-367
16 num_units: 3
17 options:
18 cluster-partition-handling: "ignore"
19+ elasticsearch:
20+ charm: /home/ubuntu/charms/elasticsearch
21+ num_units: 3
22+ options:
23+ es-heap-size: 6
24+ kubernetes:
25+ charm: ./charms/kubernetes
26+ num_units: 3
27+ options:
28+ es-heap-size: 6
29+ nova-cloud-controller:
30+ charm: ~/charms/nova-cloud-controller
31+ num_units: 3
32+ options:
33+ es-heap-size: 6
34diff --git a/juju/ua-bundle-check.py b/juju/ua-bundle-check.py
35index 9342729..1d88db2 100755
36--- a/juju/ua-bundle-check.py
37+++ b/juju/ua-bundle-check.py
38@@ -39,7 +39,8 @@ UA Juju bundle config verification
39 """
40 HEADER_TEMPLATE += "=" * 80
41 # e.g. cs:barbican-vault-123 or ./barbican-vault
42-CHARM_REGEX_TEMPLATE = "^cs:(~.+/)?{}[-]?[0-9]*$|^[\/\.]*{}$"
43+CHARM_REGEX_TEMPLATE = "^cs:(~.+/)?{}[-]?[0-9]*$|" \
44+ "^[\/\.]*{}$|^(\.?|~)(/[^/ ]*)+/?{}$"
45
46
47 class Logger(object):
48@@ -216,8 +217,8 @@ class LocalAssertionHelpers(AssertionBase):
49 regex_str = value
50 for app in self.bundle_apps:
51 charm = self.bundle_apps[app].get('charm')
52- r = re.compile(CHARM_REGEX_TEMPLATE.format(regex_str,
53- regex_str)).match(charm)
54+ r = re.compile(CHARM_REGEX_TEMPLATE.format(
55+ regex_str, regex_str, regex_str)).match(charm)
56 if r:
57 ret.reason = ("charm {} found in bundle - skipping check".
58 format(charm))
59@@ -565,8 +566,8 @@ class UABundleChecker(object):
60 for app in self.bundle_apps:
61 regex_str = self.charm_regex
62 charm = self.bundle_apps[app].get('charm')
63- r = re.compile(CHARM_REGEX_TEMPLATE.format(regex_str,
64- regex_str)).match(charm)
65+ r = re.compile(CHARM_REGEX_TEMPLATE.format(
66+ regex_str, regex_str, regex_str)).match(charm)
67 if r:
68 self.charm_name = r[0]
69 self.applications.append(app)

Subscribers

People subscribed via source and target branches

to all changes: