From 8866b4b5aa71d7427ebf461a5a012bf3aeb9e446 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 21 Apr 2026 14:57:29 +0200 Subject: [PATCH] pkg/compose: build: use jsonmessage.DisplayStream Signed-off-by: Sebastiaan van Stijn --- pkg/compose/build_classic.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/pkg/compose/build_classic.go b/pkg/compose/build_classic.go index a5f750ae2..935fe8ec9 100644 --- a/pkg/compose/build_classic.go +++ b/pkg/compose/build_classic.go @@ -268,24 +268,21 @@ func (s *composeService) doBuildImage(ctx context.Context, project *types.Projec defer response.Body.Close() //nolint:errcheck imageID := "" - aux := func(msg jsonstream.Message) { + err = jsonmessage.DisplayStream(response.Body, buildBuff, jsonmessage.WithAuxCallback(func(msg jsonstream.Message) { var result buildtypes.Result if err := json.Unmarshal(*msg.Aux, &result); err != nil { logrus.Errorf("Failed to parse aux message: %s", err) } else { imageID = result.ID } - } - - err = jsonmessage.DisplayJSONMessagesStream(response.Body, buildBuff, progBuff.FD(), true, aux) + })) if err != nil { var jerr *jsonstream.Error if errors.As(err, &jerr) { // If no error code is set, default to 1 - if jerr.Code == 0 { - jerr.Code = 1 - } - return "", cli.StatusError{Status: jerr.Message, StatusCode: jerr.Code} + // + // TODO(thaJeztah): DisplayStream should return a errdefs Error corresponding with the status-code. + return "", cli.StatusError{Status: jerr.Message, StatusCode: max(1, jerr.Code)} } return "", err }