chromite: support --channels in PushImage BAPI endpoint
BUG=b:202716782
TEST=run_tests
Change-Id: I8421ed8ff977b6b7097e359dd319cfb932a1b0e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/3217507
Reviewed-by: George Engelbrecht <engeg@google.com>
Tested-by: George Engelbrecht <engeg@google.com>
Commit-Queue: Jack Neus <jackneus@google.com>
diff --git a/api/controller/image.py b/api/controller/image.py
index 7a42a56..a0609ac 100644
--- a/api/controller/image.py
+++ b/api/controller/image.py
@@ -164,7 +164,7 @@
base_path = chroot.full_path(sysroot_class.path)
board = build_target.name
factory_shim_location = Path(
- image_lib.GetLatestImageLink(board, pointer=LOCATION_FACTORY)).resolve()
+ image_lib.GetLatestImageLink(board, pointer=LOCATION_FACTORY)).resolve()
generated = []
dlc_func = functools.partial(image.copy_dlc_image, base_path)
@@ -458,6 +458,11 @@
kwargs['profile'] = input_proto.profile.name
if input_proto.dest_bucket:
kwargs['dest_bucket'] = input_proto.dest_bucket
+ if input_proto.channels:
+ kwargs['force_channels'] = [
+ common_pb2.Channel.Name(channel).lower()[len('channel_'):]
+ for channel in input_proto.channels
+ ]
try:
pushimage.PushImage(
input_proto.gs_image_dir,
diff --git a/api/controller/image_unittest.py b/api/controller/image_unittest.py
index 2413108..97b01d8 100644
--- a/api/controller/image_unittest.py
+++ b/api/controller/image_unittest.py
@@ -357,14 +357,16 @@
build_target_name='atlas',
profile='foo',
sign_types=None,
- dryrun=True):
+ dryrun=True,
+ channels=None):
return image_pb2.PushImageRequest(
gs_image_dir=gs_image_dir,
sysroot=sysroot_pb2.Sysroot(
build_target=common_pb2.BuildTarget(name=build_target_name)),
profile=common_pb2.Profile(name=profile),
sign_types=sign_types,
- dryrun=dryrun)
+ dryrun=dryrun,
+ channels=channels)
def testValidateOnly(self):
"""Check that a validate only call does not execute any logic."""
@@ -431,7 +433,8 @@
patch = self.PatchObject(pushimage, 'PushImage')
request = self._GetRequest(
- dryrun=False, profile='', sign_types=[common_pb2.IMAGE_TYPE_RECOVERY])
+ dryrun=False, profile='', sign_types=[common_pb2.IMAGE_TYPE_RECOVERY],
+ channels=[common_pb2.CHANNEL_DEV, common_pb2.CHANNEL_CANARY])
request.dest_bucket = 'gs://foo'
image_controller.PushImage(request, self.response, self.api_config)
patch.assert_called_with(
@@ -439,7 +442,8 @@
request.sysroot.build_target.name,
dry_run=request.dryrun,
sign_types=['recovery'],
- dest_bucket=request.dest_bucket)
+ dest_bucket=request.dest_bucket,
+ force_channels=['dev', 'canary'])
def testCallSucceeds(self):
"""Check that a (dry run) call is made successfully."""