Build API: Implement validate_only calls.
Add validate-only support to all existing endpoints and
tests to enforce the setting is respected.
Add is_in validator to help transition some endpoints
to decorator-only validation.
Some cleanup and standardization in the controller tests.
BUG=chromium:987263
TEST=run_tests
Cq-Depend: chromium:1726252
Change-Id: I108dfc1a221847eae47a18f2f60e12d2575c9ea8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1726253
Reviewed-by: David Burger <dburger@chromium.org>
Commit-Queue: Alex Klein <saklein@chromium.org>
Tested-by: Alex Klein <saklein@chromium.org>
diff --git a/api/controller/sysroot.py b/api/controller/sysroot.py
index dcccaa0..dd37b3f 100644
--- a/api/controller/sysroot.py
+++ b/api/controller/sysroot.py
@@ -21,7 +21,8 @@
@validate.require('build_target.name')
-def Create(input_proto, output_proto):
+@validate.validation_complete
+def Create(input_proto, output_proto, _config):
"""Create or replace a sysroot."""
update_chroot = not input_proto.flags.chroot_current
replace_sysroot = input_proto.flags.replace
@@ -45,7 +46,9 @@
@validate.require('sysroot.path', 'sysroot.build_target.name')
-def InstallToolchain(input_proto, output_proto):
+@validate.exists('sysroot.path')
+@validate.validation_complete
+def InstallToolchain(input_proto, output_proto, _config):
"""Install the toolchain into a sysroot."""
compile_source = input_proto.flags.compile_source
@@ -56,9 +59,6 @@
target_sysroot = sysroot_lib.Sysroot(sysroot_path)
run_configs = sysroot.SetupBoardRunConfig(usepkg=not compile_source)
- if not target_sysroot.Exists():
- cros_build_lib.Die('Sysroot has not been created. Run Create first.')
-
_LogBinhost(build_target.name)
try:
@@ -73,7 +73,8 @@
@validate.require('sysroot.path', 'sysroot.build_target.name')
-def InstallPackages(input_proto, output_proto):
+@validate.validation_complete
+def InstallPackages(input_proto, output_proto, _config):
"""Install packages into a sysroot, building as necessary and permitted."""
compile_source = input_proto.flags.compile_source
event_file = input_proto.flags.event_file