Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3100)

Unified Diff: appengine/swarming/cipd.py

Issue 1946253003: swarming: refactor cipd input (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@default-isolate-server
Patch Set: rebased Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/components/components/config/validation.py ('k') | appengine/swarming/handlers_bot.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/swarming/cipd.py
diff --git a/appengine/swarming/cipd.py b/appengine/swarming/cipd.py
index 3f33067ccbffbfa03d9f21b4ed9ef90de19e9ccf..338b69cb5a6a54544487f7ff3d225c36063aa853 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
+# 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", "amd64" or "arm".
+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)
« no previous file with comments | « appengine/components/components/config/validation.py ('k') | appengine/swarming/handlers_bot.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698