mirror of
https://github.com/distribution/distribution.git
synced 2025-10-22 03:24:17 +00:00
replace uses of Descriptor alias
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
events "github.com/docker/go-events"
|
||||
"github.com/google/uuid"
|
||||
"github.com/opencontainers/go-digest"
|
||||
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
type bridge struct {
|
||||
@@ -90,15 +91,15 @@ func (b *bridge) ManifestDeleted(repo reference.Named, dgst digest.Digest) error
|
||||
return b.createManifestDeleteEventAndWrite(EventActionDelete, repo, dgst)
|
||||
}
|
||||
|
||||
func (b *bridge) BlobPushed(repo reference.Named, desc distribution.Descriptor) error {
|
||||
func (b *bridge) BlobPushed(repo reference.Named, desc v1.Descriptor) error {
|
||||
return b.createBlobEventAndWrite(EventActionPush, repo, desc)
|
||||
}
|
||||
|
||||
func (b *bridge) BlobPulled(repo reference.Named, desc distribution.Descriptor) error {
|
||||
func (b *bridge) BlobPulled(repo reference.Named, desc v1.Descriptor) error {
|
||||
return b.createBlobEventAndWrite(EventActionPull, repo, desc)
|
||||
}
|
||||
|
||||
func (b *bridge) BlobMounted(repo reference.Named, desc distribution.Descriptor, fromRepo reference.Named) error {
|
||||
func (b *bridge) BlobMounted(repo reference.Named, desc v1.Descriptor, fromRepo reference.Named) error {
|
||||
event, err := b.createBlobEvent(EventActionMount, repo, desc)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -178,7 +179,7 @@ func (b *bridge) createBlobDeleteEventAndWrite(action string, repo reference.Nam
|
||||
return b.sink.Write(*event)
|
||||
}
|
||||
|
||||
func (b *bridge) createBlobEventAndWrite(action string, repo reference.Named, desc distribution.Descriptor) error {
|
||||
func (b *bridge) createBlobEventAndWrite(action string, repo reference.Named, desc v1.Descriptor) error {
|
||||
event, err := b.createBlobEvent(action, repo, desc)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -187,7 +188,7 @@ func (b *bridge) createBlobEventAndWrite(action string, repo reference.Named, de
|
||||
return b.sink.Write(*event)
|
||||
}
|
||||
|
||||
func (b *bridge) createBlobEvent(action string, repo reference.Named, desc distribution.Descriptor) (*Event, error) {
|
||||
func (b *bridge) createBlobEvent(action string, repo reference.Named, desc v1.Descriptor) (*Event, error) {
|
||||
event := b.createEvent(action)
|
||||
event.Target.Descriptor = desc
|
||||
event.Target.Length = desc.Size
|
||||
|
@@ -30,7 +30,7 @@ var (
|
||||
request = RequestRecord{}
|
||||
tag = "latest"
|
||||
artifactType = "application/vnd.example.sbom.v1"
|
||||
cfg = distribution.Descriptor{
|
||||
cfg = v1.Descriptor{
|
||||
MediaType: artifactType,
|
||||
Size: 100,
|
||||
Digest: "cfgdgst",
|
||||
|
@@ -4,8 +4,8 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/distribution/distribution/v3"
|
||||
events "github.com/docker/go-events"
|
||||
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
// EventAction constants used in action field of Event.
|
||||
@@ -54,7 +54,7 @@ type Event struct {
|
||||
Target struct {
|
||||
// TODO(stevvooe): Use http.DetectContentType for layers, maybe.
|
||||
|
||||
distribution.Descriptor
|
||||
v1.Descriptor
|
||||
|
||||
// Length in bytes of content. Same as Size field in Descriptor.
|
||||
// Provided for backwards compatibility.
|
||||
@@ -74,7 +74,7 @@ type Event struct {
|
||||
Tag string `json:"tag,omitempty"`
|
||||
|
||||
// References provides the references descriptors.
|
||||
References []distribution.Descriptor `json:"references,omitempty"`
|
||||
References []v1.Descriptor `json:"references,omitempty"`
|
||||
} `json:"target,omitempty"`
|
||||
|
||||
// Request covers the request that generated the event.
|
||||
|
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/distribution/distribution/v3/internal/dcontext"
|
||||
"github.com/distribution/reference"
|
||||
"github.com/opencontainers/go-digest"
|
||||
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
// ManifestListener describes a set of methods for listening to events related to manifests.
|
||||
@@ -21,9 +22,9 @@ type ManifestListener interface {
|
||||
|
||||
// BlobListener describes a listener that can respond to layer related events.
|
||||
type BlobListener interface {
|
||||
BlobPushed(repo reference.Named, desc distribution.Descriptor) error
|
||||
BlobPulled(repo reference.Named, desc distribution.Descriptor) error
|
||||
BlobMounted(repo reference.Named, desc distribution.Descriptor, fromRepo reference.Named) error
|
||||
BlobPushed(repo reference.Named, desc v1.Descriptor) error
|
||||
BlobPulled(repo reference.Named, desc v1.Descriptor) error
|
||||
BlobMounted(repo reference.Named, desc v1.Descriptor, fromRepo reference.Named) error
|
||||
BlobDeleted(repo reference.Named, desc digest.Digest) error
|
||||
}
|
||||
|
||||
@@ -178,7 +179,7 @@ func (bsl *blobServiceListener) ServeBlob(ctx context.Context, w http.ResponseWr
|
||||
return err
|
||||
}
|
||||
|
||||
func (bsl *blobServiceListener) Put(ctx context.Context, mediaType string, p []byte) (distribution.Descriptor, error) {
|
||||
func (bsl *blobServiceListener) Put(ctx context.Context, mediaType string, p []byte) (v1.Descriptor, error) {
|
||||
desc, err := bsl.BlobStore.Put(ctx, mediaType, p)
|
||||
if err == nil {
|
||||
if err := bsl.parent.listener.BlobPushed(bsl.parent.Repository.Named(), desc); err != nil {
|
||||
@@ -229,7 +230,7 @@ type blobWriterListener struct {
|
||||
parent *blobServiceListener
|
||||
}
|
||||
|
||||
func (bwl *blobWriterListener) Commit(ctx context.Context, desc distribution.Descriptor) (distribution.Descriptor, error) {
|
||||
func (bwl *blobWriterListener) Commit(ctx context.Context, desc v1.Descriptor) (v1.Descriptor, error) {
|
||||
committed, err := bwl.BlobWriter.Commit(ctx, desc)
|
||||
if err == nil {
|
||||
if err := bwl.parent.parent.listener.BlobPushed(bwl.parent.parent.Repository.Named(), committed); err != nil {
|
||||
|
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/distribution/reference"
|
||||
"github.com/opencontainers/go-digest"
|
||||
"github.com/opencontainers/image-spec/specs-go"
|
||||
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
func TestListener(t *testing.T) {
|
||||
@@ -80,17 +81,17 @@ func (tl *testListener) ManifestDeleted(repo reference.Named, d digest.Digest) e
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tl *testListener) BlobPushed(repo reference.Named, desc distribution.Descriptor) error {
|
||||
func (tl *testListener) BlobPushed(repo reference.Named, desc v1.Descriptor) error {
|
||||
tl.ops["layer:push"]++
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tl *testListener) BlobPulled(repo reference.Named, desc distribution.Descriptor) error {
|
||||
func (tl *testListener) BlobPulled(repo reference.Named, desc v1.Descriptor) error {
|
||||
tl.ops["layer:pull"]++
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tl *testListener) BlobMounted(repo reference.Named, desc distribution.Descriptor, fromRepo reference.Named) error {
|
||||
func (tl *testListener) BlobMounted(repo reference.Named, desc v1.Descriptor, fromRepo reference.Named) error {
|
||||
tl.ops["layer:mount"]++
|
||||
return nil
|
||||
}
|
||||
@@ -146,7 +147,7 @@ func checkTestRepository(t *testing.T, repository distribution.Repository, remov
|
||||
m := schema2.Manifest{
|
||||
Versioned: specs.Versioned{SchemaVersion: 2},
|
||||
MediaType: schema2.MediaTypeManifest,
|
||||
Config: distribution.Descriptor{
|
||||
Config: v1.Descriptor{
|
||||
MediaType: "foo/bar",
|
||||
Digest: configDgst,
|
||||
},
|
||||
@@ -163,7 +164,7 @@ func checkTestRepository(t *testing.T, repository distribution.Repository, remov
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
m.Layers = append(m.Layers, distribution.Descriptor{
|
||||
m.Layers = append(m.Layers, v1.Descriptor{
|
||||
MediaType: "application/octet-stream",
|
||||
Digest: dgst,
|
||||
})
|
||||
@@ -201,7 +202,7 @@ func checkTestRepository(t *testing.T, repository distribution.Repository, remov
|
||||
t.Fatal("mismatching digest from payload and put")
|
||||
}
|
||||
|
||||
if err := repository.Tags(ctx).Tag(ctx, tag, distribution.Descriptor{Digest: dgst}); err != nil {
|
||||
if err := repository.Tags(ctx).Tag(ctx, tag, v1.Descriptor{Digest: dgst}); err != nil {
|
||||
t.Fatalf("unexpected error tagging manifest: %v", err)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user