Merge pull request #1858 from RichardScothern/decouple
Decouple storage components by redefining dependencies as interfaces
This commit is contained in:
commit
f56b143dc8
4 changed files with 15 additions and 27 deletions
|
@ -12,8 +12,8 @@ import (
|
|||
|
||||
// manifestListHandler is a ManifestHandler that covers schema2 manifest lists.
|
||||
type manifestListHandler struct {
|
||||
repository *repository
|
||||
blobStore *linkedBlobStore
|
||||
repository distribution.Repository
|
||||
blobStore distribution.BlobStore
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
|
@ -53,11 +53,6 @@ func (ms *manifestListHandler) Put(ctx context.Context, manifestList distributio
|
|||
return "", err
|
||||
}
|
||||
|
||||
// Link the revision into the repository.
|
||||
if err := ms.blobStore.linkBlob(ctx, revision); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return revision.Digest, nil
|
||||
}
|
||||
|
||||
|
@ -72,6 +67,7 @@ func (ms *manifestListHandler) verifyManifest(ctx context.Context, mnfst manifes
|
|||
// This manifest service is different from the blob service
|
||||
// returned by Blob. It uses a linked blob store to ensure that
|
||||
// only manifests are accessible.
|
||||
|
||||
manifestService, err := ms.repository.Manifests(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -217,9 +217,10 @@ func (repo *repository) Manifests(ctx context.Context, options ...distribution.M
|
|||
repository: repo,
|
||||
blobStore: blobStore,
|
||||
schema1Handler: &signedManifestHandler{
|
||||
ctx: ctx,
|
||||
repository: repo,
|
||||
blobStore: blobStore,
|
||||
ctx: ctx,
|
||||
schema1SigningKey: repo.schema1SigningKey,
|
||||
repository: repo,
|
||||
blobStore: blobStore,
|
||||
},
|
||||
schema2Handler: &schema2ManifestHandler{
|
||||
ctx: ctx,
|
||||
|
|
|
@ -21,8 +21,8 @@ var (
|
|||
|
||||
//schema2ManifestHandler is a ManifestHandler that covers schema2 manifests.
|
||||
type schema2ManifestHandler struct {
|
||||
repository *repository
|
||||
blobStore *linkedBlobStore
|
||||
repository distribution.Repository
|
||||
blobStore distribution.BlobStore
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
|
@ -62,11 +62,6 @@ func (ms *schema2ManifestHandler) Put(ctx context.Context, manifest distribution
|
|||
return "", err
|
||||
}
|
||||
|
||||
// Link the revision into the repository.
|
||||
if err := ms.blobStore.linkBlob(ctx, revision); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return revision.Digest, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -15,9 +15,10 @@ import (
|
|||
// signedManifestHandler is a ManifestHandler that covers schema1 manifests. It
|
||||
// can unmarshal and put schema1 manifests that have been signed by libtrust.
|
||||
type signedManifestHandler struct {
|
||||
repository *repository
|
||||
blobStore *linkedBlobStore
|
||||
ctx context.Context
|
||||
repository distribution.Repository
|
||||
schema1SigningKey libtrust.PrivateKey
|
||||
blobStore distribution.BlobStore
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
var _ ManifestHandler = &signedManifestHandler{}
|
||||
|
@ -35,8 +36,8 @@ func (ms *signedManifestHandler) Unmarshal(ctx context.Context, dgst digest.Dige
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if ms.repository.schema1SigningKey != nil {
|
||||
if err := jsig.Sign(ms.repository.schema1SigningKey); err != nil {
|
||||
if ms.schema1SigningKey != nil {
|
||||
if err := jsig.Sign(ms.schema1SigningKey); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
@ -75,11 +76,6 @@ func (ms *signedManifestHandler) Put(ctx context.Context, manifest distribution.
|
|||
return "", err
|
||||
}
|
||||
|
||||
// Link the revision into the repository.
|
||||
if err := ms.blobStore.linkBlob(ctx, revision); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return revision.Digest, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue