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

Side by Side 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: nits 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2016 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed by the Apache v2.0 license that can be
3 # found in the LICENSE file.
4
5 """CIPD-specific code is concentrated here."""
6
7 import re
8
9 # Regular expressions below are copied from
10 # https://chromium.googlesource.com/infra/infra/+/468bb43/appengine/chrome_infra _packages/cipd/impl.py
Paweł Hajdan Jr. 2016/04/26 08:45:22 How about a TODO to move chrome_infra_packages to
nodir 2016/04/29 22:28:08 I talked to Vadim, he is not planning to move chro
11 # https://chromium.googlesource.com/infra/infra/+/468bb43/appengine/chrome_infra _packages/cas/impl.py
12
13 PACKAGE_NAME_RE = re.compile(r'^([a-z0-9_\-]+/)*[a-z0-9_\-]+$')
14 INSTANCE_ID_RE = re.compile(r'^[0-9a-f]{40}$')
15 TAG_KEY_RE = re.compile(r'^[a-z0-9_\-]$')
16 REF_RE = re.compile(r'^[a-z0-9_\-]{1,100}$')
17 TAG_MAX_LEN = 400
18
19
20 def is_valid_package_name(package_name):
21 """Returns True if |package_name| is a valid CIPD package name."""
22 return bool(PACKAGE_NAME_RE.match(package_name))
23
24
25 def is_valid_version(version):
26 """Returns True if |version| is a valid CIPD package version."""
27 return bool(
28 INSTANCE_ID_RE.match(version) or
29 is_valid_tag(version) or
30 REF_RE.match(version)
31 )
32
33 def is_valid_tag(tag):
34 """True if string looks like a valid package instance tag."""
35 if not tag or ':' not in tag or len(tag) > TAG_MAX_LEN:
36 return False
37 # Care only about the key. Value can be anything (including empty string).
38 return bool(TAG_KEY_RE.match(tag.split(':', 1)[0]))
39
40
41 def is_pinned_version(version):
42 """Returns True if |version| is pinned."""
43 return bool(INSTANCE_ID_RE.match(version) or TAG_KEY_RE.match(version))
OLDNEW
« 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