Merge pull request #51156 from corhere/client-pkg-jsonmessage

client/pkg/jsonmessage: refactor in terms of `api/types/jsonstream`
This commit is contained in:
Paweł Gronowski
2025-10-30 19:33:21 +01:00
committed by GitHub
17 changed files with 110 additions and 188 deletions

View File

@@ -15,6 +15,7 @@ import (
cerrdefs "github.com/containerd/errdefs"
"github.com/moby/go-archive"
"github.com/moby/moby/api/types/build"
"github.com/moby/moby/api/types/jsonstream"
"github.com/moby/moby/client"
"github.com/moby/moby/client/pkg/jsonmessage"
"github.com/moby/moby/v2/integration/internal/container"
@@ -214,7 +215,7 @@ func makeTestImage(ctx context.Context, t *testing.T) (imageID string) {
assert.NilError(t, err)
defer resp.Body.Close()
err = jsonmessage.DisplayJSONMessagesStream(resp.Body, io.Discard, 0, false, func(msg jsonmessage.JSONMessage) {
err = jsonmessage.DisplayJSONMessagesStream(resp.Body, io.Discard, 0, false, func(msg jsonstream.Message) {
var r build.Result
assert.NilError(t, json.Unmarshal(*msg.Aux, &r))
imageID = r.ID
@@ -289,7 +290,7 @@ func TestCopyFromContainer(t *testing.T) {
defer resp.Body.Close()
var imageID string
err = jsonmessage.DisplayJSONMessagesStream(resp.Body, io.Discard, 0, false, func(msg jsonmessage.JSONMessage) {
err = jsonmessage.DisplayJSONMessagesStream(resp.Body, io.Discard, 0, false, func(msg jsonstream.Message) {
var r build.Result
assert.NilError(t, json.Unmarshal(*msg.Aux, &r))
imageID = r.ID

View File

@@ -5,8 +5,8 @@ import (
"strings"
"testing"
"github.com/moby/moby/api/types/jsonstream"
"github.com/moby/moby/client"
"github.com/moby/moby/client/pkg/jsonmessage"
"github.com/moby/moby/v2/integration/internal/container"
"github.com/moby/moby/v2/internal/testutil"
"github.com/moby/moby/v2/internal/testutil/daemon"
@@ -39,7 +39,7 @@ func TestExportContainerAndImportImage(t *testing.T) {
// the image ID and match with the output from `docker images`.
dec := json.NewDecoder(importRes)
var jm jsonmessage.JSONMessage
var jm jsonstream.Message
err = dec.Decode(&jm)
assert.NilError(t, err)