build-containers: Modify code to pass in tags and labels.
BUG=b:200472226
TEST=build_api call, successfully built containers
Change-Id: I9912ba52958ad9961119e8af538542a7cda5b0d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/3187266
Reviewed-by: Alex Klein <saklein@chromium.org>
Tested-by: Sean McAllister <smcallis@google.com>
Commit-Queue: Sean McAllister <smcallis@google.com>
diff --git a/api/controller/test.py b/api/controller/test.py
index 62e4dd1..59492aa 100644
--- a/api/controller/test.py
+++ b/api/controller/test.py
@@ -228,19 +228,27 @@
@faux.error(_BuildTestServiceContainersFailedResponse)
@validate.require('build_target.name')
@validate.require('chroot.path')
-@validate.require('version')
@validate.check_constraint('tags', _ValidDockerTag)
@validate.check_constraint('labels', _ValidDockerLabelKey)
@validate.validation_complete
-def BuildTestServiceContainers(input_proto, output_proto, _config):
+def BuildTestServiceContainers(
+ input_proto: test_pb2.BuildTestServiceContainersRequest,
+ output_proto: test_pb2.BuildTestServiceContainersResponse, _config):
"""Builds docker containers for all test services and pushes them to gcr.io"""
build_target = controller_util.ParseBuildTarget(input_proto.build_target)
chroot = controller_util.ParseChroot(input_proto.chroot)
- version = input_proto.version
sysroot = sysroot_lib.Sysroot(build_target.root)
+ tags = ','.join(input_proto.tags)
+ labels = (
+ '{}={}'.format(key, value) for key, value in input_proto.labels.items()
+ )
+
for build_script in TEST_CONTAINER_BUILD_SCRIPTS:
- cmd = [build_script, chroot.path, version.lower(), sysroot.path]
+ cmd = [build_script, chroot.path, sysroot.path]
+ cmd += ['--tags', tags]
+ cmd += labels
+
cmd_result = cros_build_lib.run(cmd, check=False)
if cmd_result.returncode == 0:
output_proto.results.append(test_pb2.TestServiceContainerBuildResult(