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

Unified Diff: appengine/swarming/handlers_endpoints.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: fix import google.protobuf 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
Index: appengine/swarming/handlers_endpoints.py
diff --git a/appengine/swarming/handlers_endpoints.py b/appengine/swarming/handlers_endpoints.py
index 394bc408ecafa278c9c6a3213c7e8ab222bf4dd8..24c1724a34ca085a2232892d6b47d8f57d68c331 100644
--- a/appengine/swarming/handlers_endpoints.py
+++ b/appengine/swarming/handlers_endpoints.py
@@ -77,6 +77,24 @@ def get_result_entity(task_id):
return get_or_raise(key)
+def apply_property_defaults(properties):
+ """Fills task properties with default values read from server settings."""
+ cfg = config.settings()
+ if not cfg:
+ return
+
+ if cfg.isolate.default_server and cfg.isolate.default_namespace:
+ properties.inputs_ref = properties.inputs_ref or swarming_rpcs.FilesRef()
+ properties.inputs_ref.isolatedserver = (
+ properties.inputs_ref.isolatedserver or cfg.isolate.default_server)
+ properties.inputs_ref.namespace = (
+ properties.inputs_ref.namespace or cfg.isolate.default_namespace)
+
+ cipd_input = properties.cipd_input
+ if cipd_input and not cipd_input.settings and cfg.HasField('cipd'):
+ cipd_input.settings = cfg.cipd.SerializeToString()
+
+
### API
@@ -271,17 +289,7 @@ class SwarmingTasksService(remote.Service):
if request.properties is None:
raise endpoints.BadRequestException('properties are required')
- # Apply isolate defaults.
- cfg = config.settings()
- if cfg.isolate.default_server and cfg.isolate.default_namespace:
- request.properties.inputs_ref = (
- request.properties.inputs_ref or swarming_rpcs.FilesRef())
- request.properties.inputs_ref.isolatedserver = (
- request.properties.inputs_ref.isolatedserver or
- cfg.isolate.default_server)
- request.properties.inputs_ref.namespace = (
- request.properties.inputs_ref.namespace or
- cfg.isolate.default_namespace)
+ apply_property_defaults(request.properties)
try:
request = message_conversion.new_task_request_from_rpc(

Powered by Google App Engine
This is Rietveld 408576698