From ebe464ea4563fc61b2fd49ddd7dc32fe8039fa80 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 31 Oct 2025 00:44:41 +0100 Subject: [PATCH] api/types: remove PushResult type, and move internal This type was used as Aux message for docker push, was not documented, and only present for Docker Content Trust (which is deprecated). This patch removes it from the API module, and moves the type internal. We can stop sending this Aux message once DCT is fully phased out. Signed-off-by: Sebastiaan van Stijn --- api/types/types.go | 9 --------- daemon/internal/distribution/push_v2.go | 14 +++++++++++-- daemon/pkg/plugin/backend_linux.go | 14 +++++++++++-- integration/plugin/common/plugin_test.go | 20 ++++++++++++++----- .../github.com/moby/moby/api/types/types.go | 9 --------- 5 files changed, 39 insertions(+), 27 deletions(-) diff --git a/api/types/types.go b/api/types/types.go index 8457ca0411..c74cec0b29 100644 --- a/api/types/types.go +++ b/api/types/types.go @@ -43,12 +43,3 @@ type Version struct { Experimental bool `json:",omitempty"` BuildTime string `json:",omitempty"` } - -// PushResult contains the tag, manifest digest, and manifest size from the -// push. It's used to signal this information to the trust code in the client -// so it can sign the manifest if necessary. -type PushResult struct { - Tag string - Digest string - Size int -} diff --git a/daemon/internal/distribution/push_v2.go b/daemon/internal/distribution/push_v2.go index e432cf6bff..4465b9175f 100644 --- a/daemon/internal/distribution/push_v2.go +++ b/daemon/internal/distribution/push_v2.go @@ -14,7 +14,6 @@ import ( "github.com/docker/distribution/manifest/schema2" "github.com/docker/distribution/registry/api/errcode" "github.com/docker/distribution/registry/client" - apitypes "github.com/moby/moby/api/types" "github.com/moby/moby/v2/daemon/internal/distribution/metadata" "github.com/moby/moby/v2/daemon/internal/distribution/xfer" "github.com/moby/moby/v2/daemon/internal/layer" @@ -211,9 +210,20 @@ func (p *pusher) pushTag(ctx context.Context, ref reference.NamedTagged, id dige return err } + // pushResult contains the tag, manifest digest, and manifest size from the + // push. It's used to signal this information to the trust code in the client + // so it can sign the manifest if necessary. + // + // TODO(thaJeztah): this aux-type is only present for docker content trust, which is deprecated. + type pushResult struct { + Tag string + Digest string + Size int + } + // Signal digest to the trust client so it can sign the // push, if appropriate. - progress.Aux(p.config.ProgressOutput, apitypes.PushResult{Tag: ref.Tag(), Digest: manifestDigest.String(), Size: len(canonicalManifest)}) + progress.Aux(p.config.ProgressOutput, pushResult{Tag: ref.Tag(), Digest: manifestDigest.String(), Size: len(canonicalManifest)}) return nil } diff --git a/daemon/pkg/plugin/backend_linux.go b/daemon/pkg/plugin/backend_linux.go index 6470ab5e4f..6fc2325c1f 100644 --- a/daemon/pkg/plugin/backend_linux.go +++ b/daemon/pkg/plugin/backend_linux.go @@ -22,7 +22,6 @@ import ( "github.com/containerd/platforms" "github.com/distribution/reference" "github.com/moby/go-archive/chrootarchive" - "github.com/moby/moby/api/types" "github.com/moby/moby/api/types/events" "github.com/moby/moby/api/types/plugin" "github.com/moby/moby/api/types/registry" @@ -464,8 +463,19 @@ func (pm *Manager) Push(ctx context.Context, name string, metaHeader http.Header progress.Update(out, pj.names[j], "Upload complete") } + // pushResult contains the tag, manifest digest, and manifest size from the + // push. It's used to signal this information to the trust code in the client + // so it can sign the manifest if necessary. + // + // TODO(thaJeztah): this aux-type is only present for docker content trust, which is deprecated. + type pushResult struct { + Tag string + Digest string + Size int + } + // Signal the client for content trust verification - progress.Aux(out, types.PushResult{Tag: ref.(reference.Tagged).Tag(), Digest: desc.Digest.String(), Size: int(desc.Size)}) + progress.Aux(out, pushResult{Tag: ref.(reference.Tagged).Tag(), Digest: desc.Digest.String(), Size: int(desc.Size)}) return nil } diff --git a/integration/plugin/common/plugin_test.go b/integration/plugin/common/plugin_test.go index edc2d20157..e0d981288e 100644 --- a/integration/plugin/common/plugin_test.go +++ b/integration/plugin/common/plugin_test.go @@ -15,7 +15,6 @@ import ( c8dimages "github.com/containerd/containerd/v2/core/images" "github.com/containerd/containerd/v2/core/remotes/docker" - "github.com/moby/moby/api/types" "github.com/moby/moby/api/types/jsonstream" registrytypes "github.com/moby/moby/api/types/registry" "github.com/moby/moby/api/types/system" @@ -136,16 +135,27 @@ func TestPluginInstall(t *testing.T) { err := plugin.Create(ctx, apiclient, repo) assert.NilError(t, err) - pushResult, err := apiclient.PluginPush(ctx, repo, client.PluginPushOptions{}) + res, err := apiclient.PluginPush(ctx, repo, client.PluginPushOptions{}) assert.NilError(t, err) - defer pushResult.Close() + defer res.Close() buf := &strings.Builder{} assert.NilError(t, err) var digest string - assert.NilError(t, jsonmessage.DisplayJSONMessagesStream(pushResult, buf, 0, false, func(j jsonstream.Message) { + + // PushResult contains the tag, manifest digest, and manifest size from the + // push. It's used to signal this information to the trust code in the client + // so it can sign the manifest if necessary. + // + // TODO(thaJeztah): this aux-type is only present for docker content trust, which is deprecated. + type pushResult struct { + Tag string + Digest string + Size int + } + assert.NilError(t, jsonmessage.DisplayJSONMessagesStream(res, buf, 0, false, func(j jsonstream.Message) { if j.Aux != nil { - var r types.PushResult + var r pushResult assert.NilError(t, json.Unmarshal(*j.Aux, &r)) digest = r.Digest } diff --git a/vendor/github.com/moby/moby/api/types/types.go b/vendor/github.com/moby/moby/api/types/types.go index 8457ca0411..c74cec0b29 100644 --- a/vendor/github.com/moby/moby/api/types/types.go +++ b/vendor/github.com/moby/moby/api/types/types.go @@ -43,12 +43,3 @@ type Version struct { Experimental bool `json:",omitempty"` BuildTime string `json:",omitempty"` } - -// PushResult contains the tag, manifest digest, and manifest size from the -// push. It's used to signal this information to the trust code in the client -// so it can sign the manifest if necessary. -type PushResult struct { - Tag string - Digest string - Size int -}