Merge ~hopem/stsstack-bundles:revision-info-fixes into stsstack-bundles:master

Proposed by Edward Hope-Morley
Status: Merged
Merged at revision: 6914bd8bd4967ef0e04c848f73d531c6b3db6021
Proposed branch: ~hopem/stsstack-bundles:revision-info-fixes
Merge into: stsstack-bundles:master
Diff against target: 69 lines (+26/-8)
2 files modified
common/helpers (+8/-6)
tools/parse-bundle.py (+18/-2)
Reviewer Review Type Date Requested Status
Nicolas Bock (community) Approve
Jolly Bundlers Pending
Review via email: mp+384652@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Nicolas Bock (nicolasbock) :
review: Needs Fixing
Revision history for this message
Edward Hope-Morley (hopem) :
Revision history for this message
Edward Hope-Morley (hopem) wrote :

all fixed

Revision history for this message
Nicolas Bock (nicolasbock) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/common/helpers b/common/helpers
2index 3aba5bd..ddfb55e 100644
3--- a/common/helpers
4+++ b/common/helpers
5@@ -192,12 +192,14 @@ filter_master_opts ()
6 exit 1
7 fi
8 readarray -t temp < <("$MOD_DIR/../tools/parse-bundle.py" --get-charms $2)
9- for line in "${temp[@]}"; do
10- read -a temp -r <<< ${line}
11- MASTER_OPTS[CHARM_REVISIONS.${temp[0]}]=${temp[1]}
12- done
13- echo "INFO: enabling stable charms since version info provided."
14- CACHED_STDIN=( "${CACHED_STDIN[@]}" --use-stable-charms )
15+ if ((${#temp[@]})); then
16+ for line in "${temp[@]}"; do
17+ read -a temp -r <<< ${line}
18+ MASTER_OPTS[CHARM_REVISIONS.${temp[0]}]=${temp[1]}
19+ done
20+ echo -e "INFO: enabling stable charms since version info provided\n"
21+ CACHED_STDIN=( "${CACHED_STDIN[@]}" --use-stable-charms )
22+ fi
23 shift
24 ;;
25 --debug)
26diff --git a/tools/parse-bundle.py b/tools/parse-bundle.py
27index 755cc5d..23bb594 100755
28--- a/tools/parse-bundle.py
29+++ b/tools/parse-bundle.py
30@@ -5,7 +5,9 @@ import yaml
31 import re
32 import sys
33
34-charm_match = re.compile("cs:[a-z0-9\-]+-[0-9]+\s*$")
35+lpid = r"([~a-z0-9\-]+/)?"
36+charm = r"([a-z0-9\-]+)"
37+charm_match = re.compile(r".*cs:{}{}-([0-9]+)\s*$".format(lpid, charm))
38
39
40 def parse_arguments():
41@@ -29,13 +31,27 @@ def get_charms(bundle):
42
43
44 def process(bundle_file, options):
45+ versions_found = False
46+ invalid_charms = []
47 bundle = yaml.load(bundle_file, Loader=yaml.SafeLoader)
48 if options.get_charms:
49 charms = get_charms(bundle)
50 for app in charms:
51 ret = charm_match.match(charms[app])
52 if ret:
53- print(app, charms[app])
54+ if ret.group(1):
55+ invalid_charms.append(ret.group(2))
56+ else:
57+ versions_found = True
58+ print(ret.group(2), charms[app])
59+
60+ if not versions_found:
61+ sys.stderr.write("WARNING: no valid charm revisions found in {}\n\n".
62+ format(bundle_file.name))
63+ elif invalid_charms:
64+ sys.stderr.write("WARNING: ignoring version info for non-stable "
65+ "charm(s): ")
66+ sys.stderr.write("{}\n\n".format(', '.join(invalid_charms)))
67
68
69 def main():

Subscribers

People subscribed via source and target branches