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

Unified Diff: appengine/swarming/cipd.py

Issue 1910713002: swarming: add support for cipd on the server side (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@master
Patch Set: swarming: add cipd packages on the server side Created 4 years, 8 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 | « no previous file | appengine/swarming/handlers_bot.py » ('j') | appengine/swarming/server/task_request.py » ('J')
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
new file mode 100644
index 0000000000000000000000000000000000000000..bca3eb09786e375c7d9fab92d5765412e38022a9
--- /dev/null
+++ b/appengine/swarming/cipd.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
M-A Ruel 2016/04/25 19:09:45 THis file is not executable.
nodir 2016/04/25 20:27:15 Done.
+# Copyright 2016 The LUCI Authors. All rights reserved.
+# Use of this source code is governed by the Apache v2.0 license that can be
+# found in the LICENSE file.
+
+"""CIPD-specific code is concentrated here."""
+
+import re
+
+# Regular expressions below are copied from
+# https://chromium.googlesource.com/infra/infra/+/468bb43/appengine/chrome_infra_packages/cipd/impl.py
+# https://chromium.googlesource.com/infra/infra/+/468bb43/appengine/chrome_infra_packages/cas/impl.py
+
+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_\-]{1,400}$')
+REF_RE = re.compile(r'^[a-z0-9_\-]{1,100}$')
+
+
+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_version(version):
+ """Returns True if |version| is a valid CIPD package version."""
+ return bool(
+ INSTANCE_ID_RE.match(version) or
+ TAG_KEY_RE.match(version) or
+ REF_RE.match(version)
+ )
+
+
+def is_pinned_version(version):
+ """Returns True if |version| is pinned"""
+ return bool(INSTANCE_ID_RE.match(version) or TAG_KEY_RE.match(version))
« no previous file with comments | « no previous file | appengine/swarming/handlers_bot.py » ('j') | appengine/swarming/server/task_request.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698