Chromium Code Reviews| Index: appengine/swarming/cipd.py |
| diff --git a/appengine/swarming/cipd.py b/appengine/swarming/cipd.py |
| index 3f33067ccbffbfa03d9f21b4ed9ef90de19e9ccf..280c280f9bc07460186c9f005720c16bf55a16e2 100644 |
| --- a/appengine/swarming/cipd.py |
| +++ b/appengine/swarming/cipd.py |
| @@ -12,16 +12,39 @@ import re |
| PACKAGE_NAME_RE = re.compile(r'^([a-z0-9_\-]+/)*[a-z0-9_\-]+$') |
| INSTANCE_ID_RE = re.compile(r'^[0-9a-f]{40}$') |
| -TAG_KEY_RE = re.compile(r'^[a-z0-9_\-]$') |
| +TAG_KEY_RE = re.compile(r'^[a-z0-9_\-]+$') |
| REF_RE = re.compile(r'^[a-z0-9_\-]{1,100}$') |
| TAG_MAX_LEN = 400 |
| +# CIPD package name template parameters allow a user to reference different |
| +# packages for different enviroments. Inspired by |
| +# https://chromium.googlesource.com/infra/infra/+/f1072a132c68532b548458392c5444f04386d684/build/README.md |
|
M-A Ruel
2016/05/11 14:56:44
why not https://chromium.googlesource.com/infra/in
nodir
2016/05/12 01:53:21
I'd like to avoid broken links in case README move
|
| +# The values of the parameters are computed on the bot. |
| +# |
| +# Platform parameter value is "<os>-<arch>" string, where |
| +# os can be "linux", "mac" or "windows" and arch can be "386" or "amd64". |
|
M-A Ruel
2016/05/11 14:56:44
I'd like the comment to call out arm, arm6l or arm
nodir
2016/05/12 01:53:22
I've added etc because I cannot be more specific h
M-A Ruel
2016/05/12 13:49:45
I cross compile from Ubuntu, scp to my Raspberry P
nodir
2016/05/14 01:51:03
Done.
|
| +PARAM_PLATFORM = '${platform}' |
| +# OS version parameter defines major and minor version of the OS distribution. |
| +# It is useful if package depends on .dll/.so libraries provided by the OS. |
| +# Example values: "ubuntu14_04", "mac10_9", "win6_1". |
| +PARAM_OS_VER = '${os_ver}' |
| +ALL_PARAMS = (PARAM_PLATFORM, PARAM_OS_VER) |
| + |
| + |
| def is_valid_package_name(package_name): |
| """Returns True if |package_name| is a valid CIPD package name.""" |
| return bool(PACKAGE_NAME_RE.match(package_name)) |
| +def is_valid_package_name_template(template): |
| + """Returns True if |package_name| is a valid CIPD package name template.""" |
| + # Render known parameters first. |
| + for p in ALL_PARAMS: |
| + template = template.replace(p, 'x') |
| + return is_valid_package_name(template) |
| + |
| + |
| def is_valid_version(version): |
| """Returns True if |version| is a valid CIPD package version.""" |
| return bool( |
| @@ -30,6 +53,7 @@ def is_valid_version(version): |
| REF_RE.match(version) |
| ) |
| + |
| def is_valid_tag(tag): |
| """True if string looks like a valid package instance tag.""" |
| if not tag or ':' not in tag or len(tag) > TAG_MAX_LEN: |
| @@ -40,4 +64,4 @@ def is_valid_tag(tag): |
| def is_pinned_version(version): |
| """Returns True if |version| is pinned.""" |
| - return bool(INSTANCE_ID_RE.match(version) or TAG_KEY_RE.match(version)) |
| + return bool(INSTANCE_ID_RE.match(version)) or is_valid_tag(version) |