From 6b8f758c54593696160fcbf32f5b737c552eea92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Budai?= Date: Wed, 13 Oct 2021 15:06:59 +0200 Subject: [PATCH] cloudapi/v2: move multi-image compose check to the beginning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ondřej Budai --- internal/cloudapi/v2/v2.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/internal/cloudapi/v2/v2.go b/internal/cloudapi/v2/v2.go index 75bf804e0..88e4d11ae 100644 --- a/internal/cloudapi/v2/v2.go +++ b/internal/cloudapi/v2/v2.go @@ -147,6 +147,10 @@ func (h *apiHandlers) PostCompose(ctx echo.Context) error { return HTTPError(ErrorUnsupportedDistribution) } + if len(request.ImageRequests) != 1 { + return HTTPError(ErrorMultiImageCompose) + } + var bp = blueprint.Blueprint{} err = bp.Initialize() if err != nil { @@ -414,18 +418,10 @@ func (h *apiHandlers) PostCompose(ctx echo.Context) error { } } - var ir imageRequest - if len(imageRequests) == 1 { - // NOTE: the store currently does not support multi-image composes - ir = imageRequests[0] - } else { - return HTTPError(ErrorMultiImageCompose) - } - - id, err := h.server.workers.EnqueueOSBuild(ir.arch, &worker.OSBuildJob{ - Manifest: ir.manifest, + id, err := h.server.workers.EnqueueOSBuild(imageRequests[0].arch, &worker.OSBuildJob{ + Manifest: imageRequests[0].manifest, Targets: targets, - Exports: ir.exports, + Exports: imageRequests[0].exports, }) if err != nil { return HTTPErrorWithInternal(ErrorEnqueueingJob, err)