From 4774cbfbcbd0563a21c29c3a3646f7070ffdc895 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 21 Apr 2026 14:24:13 +0200 Subject: [PATCH 1/3] pkg/bridge: use jsonmessage.DisplayStream Signed-off-by: Sebastiaan van Stijn --- pkg/bridge/convert.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkg/bridge/convert.go b/pkg/bridge/convert.go index adf676eab4b..a07f91e2a00 100644 --- a/pkg/bridge/convert.go +++ b/pkg/bridge/convert.go @@ -232,9 +232,7 @@ func inspectWithPull(ctx context.Context, dockerCli command.Cli, imageName strin } defer func() { _ = stream.Close() }() - out := dockerCli.Out() - err = jsonmessage.DisplayJSONMessagesStream(stream, out, out.FD(), out.IsTerminal(), nil) - if err != nil { + if err := jsonmessage.DisplayStream(stream, dockerCli.Out()); err != nil { return image.InspectResponse{}, err } if inspect, err = dockerCli.Client().ImageInspect(ctx, imageName); err != nil { From 8866b4b5aa71d7427ebf461a5a012bf3aeb9e446 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 21 Apr 2026 14:57:29 +0200 Subject: [PATCH 2/3] 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 a5f750ae2dc..935fe8ec90b 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 } From 687ab2287553fd628716252fe43f4f0c9b1ed7a5 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 21 Apr 2026 15:00:11 +0200 Subject: [PATCH 3/3] pkg/bridge: LoadAdditionalResources: use port.Port Removes the need to manually convert to a string. Signed-off-by: Sebastiaan van Stijn --- pkg/bridge/convert.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/bridge/convert.go b/pkg/bridge/convert.go index a07f91e2a00..5088c4fffc8 100644 --- a/pkg/bridge/convert.go +++ b/pkg/bridge/convert.go @@ -178,7 +178,7 @@ func LoadAdditionalResources(ctx context.Context, dockerCLI command.Cli, project if err != nil { return nil, err } - exposed.Add(strconv.Itoa(int(p.Num()))) + exposed.Add(p.Port()) } for _, port := range service.Ports { exposed.Add(strconv.Itoa(int(port.Target)))