Build API config: Use a proto-based configuration
Switch the Build API to use a proto configuration rather than
CLI options. This provides cleaner backwards compatibility for
the build api itself.
BUG=chromium:1040978
TEST=run_tests
Change-Id: I515271b4244c354c38538b30dcc1cfa07517f821
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1994725
Tested-by: Alex Klein <saklein@chromium.org>
Reviewed-by: Will Bradley <wbbradley@chromium.org>
Commit-Queue: Alex Klein <saklein@chromium.org>
diff --git a/api/router.py b/api/router.py
index a9da17d..84d7599 100644
--- a/api/router.py
+++ b/api/router.py
@@ -84,6 +84,7 @@
REEXEC_INPUT_FILE = 'input.json'
REEXEC_OUTPUT_FILE = 'output.json'
+ REEXEC_CONFIG_FILE = 'config.json'
def __init__(self):
self._services = {}
@@ -265,16 +266,20 @@
chroot_input = '/%s' % os.path.relpath(new_input, chroot.path)
new_output = os.path.join(tempdir, self.REEXEC_OUTPUT_FILE)
chroot_output = '/%s' % os.path.relpath(new_output, chroot.path)
+ new_config = os.path.join(tempdir, self.REEXEC_CONFIG_FILE)
+ chroot_config = '/%s' % os.path.relpath(new_config, chroot.path)
logging.info('Writing input message to: %s', new_input)
osutils.WriteFile(new_input, json_format.MessageToJson(input_msg))
osutils.Touch(new_output)
+ logging.info('Writing config message to: %s', new_config)
+ osutils.WriteFile(new_config,
+ json_format.MessageToJson(config.get_proto()))
cmd = ['build_api', '%s/%s' % (service_name, method_name),
- '--input-json', chroot_input, '--output-json', chroot_output]
-
- if config.validate_only:
- cmd.append('--validate-only')
+ '--input-json', chroot_input,
+ '--output-json', chroot_output,
+ '--config-json', chroot_config]
try:
result = cros_build_lib.run(