From ad830a47af5e495f9b76f6457e80ceefcf7a7daf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Mon, 1 Sep 2025 16:03:16 +0200 Subject: [PATCH] integration/internal: Handle Buildkit in GetImageIDFromBody MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BuildKit emits some additional events during build and they are not `build.Result` so don't fail if we encounter one. Signed-off-by: Paweł Gronowski --- integration/internal/build/build.go | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/integration/internal/build/build.go b/integration/internal/build/build.go index b22719f1dc..b9ee9a468b 100644 --- a/integration/internal/build/build.go +++ b/integration/internal/build/build.go @@ -29,12 +29,10 @@ func Do(ctx context.Context, t *testing.T, apiClient client.APIClient, buildCtx // GetImageIDFromBody reads the image ID from the build response body. func GetImageIDFromBody(t *testing.T, body io.Reader) string { - var ( - jm jsonmessage.JSONMessage - br build.Result - dec = json.NewDecoder(body) - ) + var id string + dec := json.NewDecoder(body) for { + var jm jsonmessage.JSONMessage err := dec.Decode(&jm) if err == io.EOF { break @@ -43,10 +41,18 @@ func GetImageIDFromBody(t *testing.T, body io.Reader) string { if jm.Aux == nil { continue } - assert.NilError(t, json.Unmarshal(*jm.Aux, &br)) - assert.Assert(t, br.ID != "", "could not read image ID from build output") - break + + var br build.Result + if err := json.Unmarshal(*jm.Aux, &br); err == nil { + if br.ID == "" { + continue + } + id = br.ID + break + } } - io.Copy(io.Discard, body) - return br.ID + _, _ = io.Copy(io.Discard, body) + + assert.Assert(t, id != "", "could not read image ID from build output") + return id }