Add handling for build_target in BundleChromeOSConfig.

- Needed so this endpoint can handle current Recipes
calls that set build_target.

- Add test to api/controller/artifacts_unittest.py.

- Also add test in service/artifacts_unittest.py for
case when no config payload is found.

- Add call template for BundleChromeOSConfig.

TEST=./run_tests
BUG=chromium:987401

Change-Id: I9b7da6e5f2de71a3ada8ca36f66e594c54dc2175
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1756263
Tested-by: Andrew Lamb <andrewlamb@chromium.org>
Reviewed-by: David Burger <dburger@chromium.org>
Commit-Queue: Andrew Lamb <andrewlamb@chromium.org>
diff --git a/api/controller/artifacts.py b/api/controller/artifacts.py
index 09799d5..07f0ed4 100644
--- a/api/controller/artifacts.py
+++ b/api/controller/artifacts.py
@@ -322,9 +322,18 @@
     _config (api_config.ApiConfig): The API call config.
   """
   output_dir = input_proto.output_dir
-  sysroot = sysroot_lib.Sysroot(input_proto.sysroot.path)
+  sysroot_path = input_proto.sysroot.path
   chroot = controller_util.ParseChroot(input_proto.chroot)
 
+  # TODO(mmortensen) Cleanup legacy handling after it has been switched over.
+  target = input_proto.build_target.name
+  if target:
+    # Legacy handling.
+    build_root = constants.SOURCE_ROOT
+    chroot = chroot_lib.Chroot(path=os.path.join(build_root, 'chroot'))
+    sysroot_path = os.path.join('/build', target)
+
+  sysroot = sysroot_lib.Sysroot(sysroot_path)
   chromeos_config = artifacts.BundleChromeOSConfig(chroot, sysroot, output_dir)
   if chromeos_config is None:
     cros_build_lib.Die(