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

Unified Diff: appengine/swarming/message_conversion.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/swarming/handlers_endpoints_test.py ('k') | appengine/swarming/proto/config.proto » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/swarming/message_conversion.py
diff --git a/appengine/swarming/message_conversion.py b/appengine/swarming/message_conversion.py
index 03ea712c35eb44e5d3838a4a8b069898cf169eff..97854ed299ce350b48d5ec61dc0ed49820f56b28 100644
--- a/appengine/swarming/message_conversion.py
+++ b/appengine/swarming/message_conversion.py
@@ -102,10 +102,27 @@ def bot_event_to_rpc(entity):
def task_request_to_rpc(entity):
""""Returns a swarming_rpcs.TaskRequest from a task_request.TaskRequest."""
assert entity.__class__ is task_request.TaskRequest
+ cipd_input = None
+ if entity.properties.cipd_input:
+ client_package = None
+ if entity.properties.cipd_input.client_package:
+ client_package = _ndb_to_rpc(
+ swarming_rpcs.CipdPackage,
+ entity.properties.cipd_input.client_package)
+ cipd_input = _ndb_to_rpc(
+ swarming_rpcs.CipdInput,
+ entity.properties.cipd_input,
+ client_package=client_package,
+ packages=[
+ _ndb_to_rpc(swarming_rpcs.CipdPackage, p)
+ for p in entity.properties.cipd_input.packages
+ ])
+
inputs_ref = None
if entity.properties.inputs_ref:
inputs_ref = _ndb_to_rpc(
swarming_rpcs.FilesRef, entity.properties.inputs_ref)
+
props = entity.properties
cmd = None
if props.commands:
@@ -115,13 +132,11 @@ def task_request_to_rpc(entity):
properties = _ndb_to_rpc(
swarming_rpcs.TaskProperties,
props,
+ cipd_input=cipd_input,
command=cmd,
dimensions=_string_pairs_from_dict(props.dimensions),
env=_string_pairs_from_dict(props.env),
- inputs_ref=inputs_ref,
- packages=[
- _ndb_to_rpc(swarming_rpcs.CipdPackage, p) for p in props.packages
- ])
+ inputs_ref=inputs_ref)
return _ndb_to_rpc(
swarming_rpcs.TaskRequest,
@@ -136,22 +151,37 @@ def new_task_request_from_rpc(msg, now):
props = msg.properties
if not props:
raise ValueError('properties is required')
+
+ cipd_input = None
+ if props.cipd_input:
+ client_package = None
+ if props.cipd_input.client_package:
+ client_package = _rpc_to_ndb(
+ task_request.CipdPackage, props.cipd_input.client_package)
+ cipd_input = _rpc_to_ndb(
+ task_request.CipdInput,
+ props.cipd_input,
+ client_package=client_package,
+ packages=[
+ _rpc_to_ndb(task_request.CipdPackage, p)
+ for p in props.cipd_input.packages
+ ])
+
inputs_ref = None
if props.inputs_ref:
inputs_ref = _rpc_to_ndb(task_request.FilesRef, props.inputs_ref)
+
properties = _rpc_to_ndb(
task_request.TaskProperties,
props,
+ cipd_input=cipd_input,
# Passing command=None is supported at API level but not at NDB level.
command=props.command or [],
# Legacy, ignored.
commands=None,
dimensions={i.key: i.value for i in props.dimensions},
env={i.key: i.value for i in props.env},
- inputs_ref=inputs_ref,
- packages=[
- _rpc_to_ndb(task_request.CipdPackage, p) for p in props.packages
- ])
+ inputs_ref=inputs_ref)
return _rpc_to_ndb(
task_request.TaskRequest,
« no previous file with comments | « appengine/swarming/handlers_endpoints_test.py ('k') | appengine/swarming/proto/config.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698