| OLD | NEW |
| 1 # Copyright 2016 The LUCI Authors. All rights reserved. | 1 # Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 """CIPD-specific code is concentrated here.""" | 5 """CIPD-specific code is concentrated here.""" |
| 6 | 6 |
| 7 import re | 7 import re |
| 8 | 8 |
| 9 # Regular expressions below are copied from | 9 # Regular expressions below are copied from |
| 10 # https://chromium.googlesource.com/infra/infra/+/468bb43/appengine/chrome_infra
_packages/cipd/impl.py | 10 # https://chromium.googlesource.com/infra/infra/+/468bb43/appengine/chrome_infra
_packages/cipd/impl.py |
| 11 # https://chromium.googlesource.com/infra/infra/+/468bb43/appengine/chrome_infra
_packages/cas/impl.py | 11 # https://chromium.googlesource.com/infra/infra/+/468bb43/appengine/chrome_infra
_packages/cas/impl.py |
| 12 | 12 |
| 13 PACKAGE_NAME_RE = re.compile(r'^([a-z0-9_\-]+/)*[a-z0-9_\-]+$') | 13 PACKAGE_NAME_RE = re.compile(r'^([a-z0-9_\-]+/)*[a-z0-9_\-]+$') |
| 14 INSTANCE_ID_RE = re.compile(r'^[0-9a-f]{40}$') | 14 INSTANCE_ID_RE = re.compile(r'^[0-9a-f]{40}$') |
| 15 TAG_KEY_RE = re.compile(r'^[a-z0-9_\-]+$') | 15 TAG_KEY_RE = re.compile(r'^[a-z0-9_\-]+$') |
| 16 REF_RE = re.compile(r'^[a-z0-9_\-]{1,100}$') | 16 REF_RE = re.compile(r'^[a-z0-9_\-]{1,100}$') |
| 17 TAG_MAX_LEN = 400 | 17 TAG_MAX_LEN = 400 |
| 18 | 18 |
| 19 | 19 |
| 20 # CIPD package name template parameters allow a user to reference different | 20 # CIPD package name template parameters allow a user to reference different |
| 21 # packages for different enviroments. Inspired by | 21 # packages for different enviroments. Inspired by |
| 22 # https://chromium.googlesource.com/infra/infra/+/f1072a132c68532b548458392c5444
f04386d684/build/README.md | 22 # https://chromium.googlesource.com/infra/infra/+/f1072a132c68532b548458392c5444
f04386d684/build/README.md |
| 23 # The values of the parameters are computed on the bot. | 23 # The values of the parameters are computed on the bot. |
| 24 # | 24 # |
| 25 # Platform parameter value is "<os>-<arch>" string, where | 25 # Platform parameter value is "<os>-<arch>" string, where |
| 26 # os can be "linux", "mac" or "windows" and arch can be "386", "amd64" or "arm". | 26 # os can be "linux", "mac" or "windows" and arch can be "386", "amd64" or |
| 27 # "armv6l". |
| 27 PARAM_PLATFORM = '${platform}' | 28 PARAM_PLATFORM = '${platform}' |
| 28 # OS version parameter defines major and minor version of the OS distribution. | 29 # OS version parameter defines major and minor version of the OS distribution. |
| 29 # It is useful if package depends on .dll/.so libraries provided by the OS. | 30 # It is useful if package depends on .dll/.so libraries provided by the OS. |
| 30 # Example values: "ubuntu14_04", "mac10_9", "win6_1". | 31 # Example values: "ubuntu14_04", "mac10_9", "win6_1". |
| 31 PARAM_OS_VER = '${os_ver}' | 32 PARAM_OS_VER = '${os_ver}' |
| 32 ALL_PARAMS = (PARAM_PLATFORM, PARAM_OS_VER) | 33 ALL_PARAMS = (PARAM_PLATFORM, PARAM_OS_VER) |
| 33 | 34 |
| 34 | 35 |
| 35 def is_valid_package_name(package_name): | 36 def is_valid_package_name(package_name): |
| 36 """Returns True if |package_name| is a valid CIPD package name.""" | 37 """Returns True if |package_name| is a valid CIPD package name.""" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 58 """True if string looks like a valid package instance tag.""" | 59 """True if string looks like a valid package instance tag.""" |
| 59 if not tag or ':' not in tag or len(tag) > TAG_MAX_LEN: | 60 if not tag or ':' not in tag or len(tag) > TAG_MAX_LEN: |
| 60 return False | 61 return False |
| 61 # Care only about the key. Value can be anything (including empty string). | 62 # Care only about the key. Value can be anything (including empty string). |
| 62 return bool(TAG_KEY_RE.match(tag.split(':', 1)[0])) | 63 return bool(TAG_KEY_RE.match(tag.split(':', 1)[0])) |
| 63 | 64 |
| 64 | 65 |
| 65 def is_pinned_version(version): | 66 def is_pinned_version(version): |
| 66 """Returns True if |version| is pinned.""" | 67 """Returns True if |version| is pinned.""" |
| 67 return bool(INSTANCE_ID_RE.match(version)) or is_valid_tag(version) | 68 return bool(INSTANCE_ID_RE.match(version)) or is_valid_tag(version) |
| OLD | NEW |