Move manifest package to schema1
As we begin our march towards multi-arch, we must prepare for the reality of multiple manifest schemas. This is the beginning of a set of changes to facilitate this. We are both moving this package into its target position where it may live peacefully next to other manfiest versions. Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
parent
8c3fc2619c
commit
6712e602b0
22 changed files with 120 additions and 106 deletions
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/docker/distribution"
|
||||
"github.com/docker/distribution/context"
|
||||
"github.com/docker/distribution/digest"
|
||||
"github.com/docker/distribution/manifest"
|
||||
"github.com/docker/distribution/manifest/schema1"
|
||||
"github.com/docker/distribution/uuid"
|
||||
)
|
||||
|
||||
|
@ -53,15 +53,15 @@ func NewRequestRecord(id string, r *http.Request) RequestRecord {
|
|||
}
|
||||
}
|
||||
|
||||
func (b *bridge) ManifestPushed(repo string, sm *manifest.SignedManifest) error {
|
||||
func (b *bridge) ManifestPushed(repo string, sm *schema1.SignedManifest) error {
|
||||
return b.createManifestEventAndWrite(EventActionPush, repo, sm)
|
||||
}
|
||||
|
||||
func (b *bridge) ManifestPulled(repo string, sm *manifest.SignedManifest) error {
|
||||
func (b *bridge) ManifestPulled(repo string, sm *schema1.SignedManifest) error {
|
||||
return b.createManifestEventAndWrite(EventActionPull, repo, sm)
|
||||
}
|
||||
|
||||
func (b *bridge) ManifestDeleted(repo string, sm *manifest.SignedManifest) error {
|
||||
func (b *bridge) ManifestDeleted(repo string, sm *schema1.SignedManifest) error {
|
||||
return b.createManifestEventAndWrite(EventActionDelete, repo, sm)
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ func (b *bridge) BlobDeleted(repo string, desc distribution.Descriptor) error {
|
|||
return b.createBlobEventAndWrite(EventActionDelete, repo, desc)
|
||||
}
|
||||
|
||||
func (b *bridge) createManifestEventAndWrite(action string, repo string, sm *manifest.SignedManifest) error {
|
||||
func (b *bridge) createManifestEventAndWrite(action string, repo string, sm *schema1.SignedManifest) error {
|
||||
manifestEvent, err := b.createManifestEvent(action, repo, sm)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -86,9 +86,9 @@ func (b *bridge) createManifestEventAndWrite(action string, repo string, sm *man
|
|||
return b.sink.Write(*manifestEvent)
|
||||
}
|
||||
|
||||
func (b *bridge) createManifestEvent(action string, repo string, sm *manifest.SignedManifest) (*Event, error) {
|
||||
func (b *bridge) createManifestEvent(action string, repo string, sm *schema1.SignedManifest) (*Event, error) {
|
||||
event := b.createEvent(action)
|
||||
event.Target.MediaType = manifest.ManifestMediaType
|
||||
event.Target.MediaType = schema1.ManifestMediaType
|
||||
event.Target.Repository = repo
|
||||
|
||||
p, err := sm.Payload()
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
"github.com/docker/libtrust"
|
||||
|
||||
"github.com/docker/distribution/manifest"
|
||||
"github.com/docker/distribution/manifest/schema1"
|
||||
|
||||
"github.com/docker/distribution/registry/api/v2"
|
||||
"github.com/docker/distribution/uuid"
|
||||
|
@ -27,12 +27,12 @@ var (
|
|||
Name: "test",
|
||||
}
|
||||
request = RequestRecord{}
|
||||
m = manifest.Manifest{
|
||||
m = schema1.Manifest{
|
||||
Name: repo,
|
||||
Tag: "latest",
|
||||
}
|
||||
|
||||
sm *manifest.SignedManifest
|
||||
sm *schema1.SignedManifest
|
||||
payload []byte
|
||||
dgst digest.Digest
|
||||
)
|
||||
|
@ -80,7 +80,7 @@ func createTestEnv(t *testing.T, fn testSinkFn) Listener {
|
|||
t.Fatalf("error generating private key: %v", err)
|
||||
}
|
||||
|
||||
sm, err = manifest.Sign(&m, pk)
|
||||
sm, err = schema1.Sign(&m, pk)
|
||||
if err != nil {
|
||||
t.Fatalf("error signing manifest: %v", err)
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/docker/distribution/manifest"
|
||||
"github.com/docker/distribution/manifest/schema1"
|
||||
)
|
||||
|
||||
// TestEventJSONFormat provides silly test to detect if the event format or
|
||||
|
@ -120,7 +120,7 @@ func TestEventEnvelopeJSONFormat(t *testing.T) {
|
|||
manifestPush.Target.Digest = "sha256:0123456789abcdef0"
|
||||
manifestPush.Target.Length = 1
|
||||
manifestPush.Target.Size = 1
|
||||
manifestPush.Target.MediaType = manifest.ManifestMediaType
|
||||
manifestPush.Target.MediaType = schema1.ManifestMediaType
|
||||
manifestPush.Target.Repository = "library/test"
|
||||
manifestPush.Target.URL = "http://example.com/v2/library/test/manifests/latest"
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/distribution/manifest"
|
||||
"github.com/docker/distribution/manifest/schema1"
|
||||
)
|
||||
|
||||
// TestHTTPSink mocks out an http endpoint and notifies it under a couple of
|
||||
|
@ -75,12 +75,12 @@ func TestHTTPSink(t *testing.T) {
|
|||
{
|
||||
statusCode: http.StatusOK,
|
||||
events: []Event{
|
||||
createTestEvent("push", "library/test", manifest.ManifestMediaType)},
|
||||
createTestEvent("push", "library/test", schema1.ManifestMediaType)},
|
||||
},
|
||||
{
|
||||
statusCode: http.StatusOK,
|
||||
events: []Event{
|
||||
createTestEvent("push", "library/test", manifest.ManifestMediaType),
|
||||
createTestEvent("push", "library/test", schema1.ManifestMediaType),
|
||||
createTestEvent("push", "library/test", layerMediaType),
|
||||
createTestEvent("push", "library/test", layerMediaType),
|
||||
},
|
||||
|
|
|
@ -7,18 +7,18 @@ import (
|
|||
"github.com/docker/distribution"
|
||||
"github.com/docker/distribution/context"
|
||||
"github.com/docker/distribution/digest"
|
||||
"github.com/docker/distribution/manifest"
|
||||
"github.com/docker/distribution/manifest/schema1"
|
||||
)
|
||||
|
||||
// ManifestListener describes a set of methods for listening to events related to manifests.
|
||||
type ManifestListener interface {
|
||||
ManifestPushed(repo string, sm *manifest.SignedManifest) error
|
||||
ManifestPulled(repo string, sm *manifest.SignedManifest) error
|
||||
ManifestPushed(repo string, sm *schema1.SignedManifest) error
|
||||
ManifestPulled(repo string, sm *schema1.SignedManifest) error
|
||||
|
||||
// TODO(stevvooe): Please note that delete support is still a little shaky
|
||||
// and we'll need to propagate these in the future.
|
||||
|
||||
ManifestDeleted(repo string, sm *manifest.SignedManifest) error
|
||||
ManifestDeleted(repo string, sm *schema1.SignedManifest) error
|
||||
}
|
||||
|
||||
// BlobListener describes a listener that can respond to layer related events.
|
||||
|
@ -74,7 +74,7 @@ type manifestServiceListener struct {
|
|||
parent *repositoryListener
|
||||
}
|
||||
|
||||
func (msl *manifestServiceListener) Get(dgst digest.Digest) (*manifest.SignedManifest, error) {
|
||||
func (msl *manifestServiceListener) Get(dgst digest.Digest) (*schema1.SignedManifest, error) {
|
||||
sm, err := msl.ManifestService.Get(dgst)
|
||||
if err == nil {
|
||||
if err := msl.parent.listener.ManifestPulled(msl.parent.Repository.Name(), sm); err != nil {
|
||||
|
@ -85,7 +85,7 @@ func (msl *manifestServiceListener) Get(dgst digest.Digest) (*manifest.SignedMan
|
|||
return sm, err
|
||||
}
|
||||
|
||||
func (msl *manifestServiceListener) Put(sm *manifest.SignedManifest) error {
|
||||
func (msl *manifestServiceListener) Put(sm *schema1.SignedManifest) error {
|
||||
err := msl.ManifestService.Put(sm)
|
||||
|
||||
if err == nil {
|
||||
|
@ -97,7 +97,7 @@ func (msl *manifestServiceListener) Put(sm *manifest.SignedManifest) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func (msl *manifestServiceListener) GetByTag(tag string, options ...distribution.ManifestServiceOption) (*manifest.SignedManifest, error) {
|
||||
func (msl *manifestServiceListener) GetByTag(tag string, options ...distribution.ManifestServiceOption) (*schema1.SignedManifest, error) {
|
||||
sm, err := msl.ManifestService.GetByTag(tag, options...)
|
||||
if err == nil {
|
||||
if err := msl.parent.listener.ManifestPulled(msl.parent.Repository.Name(), sm); err != nil {
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/docker/distribution/context"
|
||||
"github.com/docker/distribution/digest"
|
||||
"github.com/docker/distribution/manifest"
|
||||
"github.com/docker/distribution/manifest/schema1"
|
||||
"github.com/docker/distribution/registry/storage"
|
||||
"github.com/docker/distribution/registry/storage/cache/memory"
|
||||
"github.com/docker/distribution/registry/storage/driver/inmemory"
|
||||
|
@ -54,18 +55,18 @@ type testListener struct {
|
|||
ops map[string]int
|
||||
}
|
||||
|
||||
func (tl *testListener) ManifestPushed(repo string, sm *manifest.SignedManifest) error {
|
||||
func (tl *testListener) ManifestPushed(repo string, sm *schema1.SignedManifest) error {
|
||||
tl.ops["manifest:push"]++
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tl *testListener) ManifestPulled(repo string, sm *manifest.SignedManifest) error {
|
||||
func (tl *testListener) ManifestPulled(repo string, sm *schema1.SignedManifest) error {
|
||||
tl.ops["manifest:pull"]++
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tl *testListener) ManifestDeleted(repo string, sm *manifest.SignedManifest) error {
|
||||
func (tl *testListener) ManifestDeleted(repo string, sm *schema1.SignedManifest) error {
|
||||
tl.ops["manifest:delete"]++
|
||||
return nil
|
||||
}
|
||||
|
@ -94,7 +95,7 @@ func checkExerciseRepository(t *testing.T, repository distribution.Repository) {
|
|||
// update counts. Basically, it would make writing tests a lot easier.
|
||||
ctx := context.Background()
|
||||
tag := "thetag"
|
||||
m := manifest.Manifest{
|
||||
m := schema1.Manifest{
|
||||
Versioned: manifest.Versioned{
|
||||
SchemaVersion: 1,
|
||||
},
|
||||
|
@ -127,7 +128,7 @@ func checkExerciseRepository(t *testing.T, repository distribution.Repository) {
|
|||
t.Fatalf("unexpected error finishing upload: %v", err)
|
||||
}
|
||||
|
||||
m.FSLayers = append(m.FSLayers, manifest.FSLayer{
|
||||
m.FSLayers = append(m.FSLayers, schema1.FSLayer{
|
||||
BlobSum: dgst,
|
||||
})
|
||||
|
||||
|
@ -144,7 +145,7 @@ func checkExerciseRepository(t *testing.T, repository distribution.Repository) {
|
|||
t.Fatalf("unexpected error generating key: %v", err)
|
||||
}
|
||||
|
||||
sm, err := manifest.Sign(&m, pk)
|
||||
sm, err := schema1.Sign(&m, pk)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error signing manifest: %v", err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue