mirror of
https://github.com/moby/moby.git
synced 2026-01-11 10:41:43 +00:00
Merge pull request #51357 from thaJeztah/internalize_pushresult
api/types: remove PushResult type, and move internal
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
9
vendor/github.com/moby/moby/api/types/types.go
generated
vendored
9
vendor/github.com/moby/moby/api/types/types.go
generated
vendored
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user