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 }