forked from TrueCloudLab/distribution
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.
|
// manifestListHandler is a ManifestHandler that covers schema2 manifest lists.
|
||||||
type manifestListHandler struct {
|
type manifestListHandler struct {
|
||||||
repository *repository
|
repository distribution.Repository
|
||||||
blobStore *linkedBlobStore
|
blobStore distribution.BlobStore
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,11 +53,6 @@ func (ms *manifestListHandler) Put(ctx context.Context, manifestList distributio
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Link the revision into the repository.
|
|
||||||
if err := ms.blobStore.linkBlob(ctx, revision); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return revision.Digest, nil
|
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
|
// This manifest service is different from the blob service
|
||||||
// returned by Blob. It uses a linked blob store to ensure that
|
// returned by Blob. It uses a linked blob store to ensure that
|
||||||
// only manifests are accessible.
|
// only manifests are accessible.
|
||||||
|
|
||||||
manifestService, err := ms.repository.Manifests(ctx)
|
manifestService, err := ms.repository.Manifests(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -217,9 +217,10 @@ func (repo *repository) Manifests(ctx context.Context, options ...distribution.M
|
||||||
repository: repo,
|
repository: repo,
|
||||||
blobStore: blobStore,
|
blobStore: blobStore,
|
||||||
schema1Handler: &signedManifestHandler{
|
schema1Handler: &signedManifestHandler{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
repository: repo,
|
schema1SigningKey: repo.schema1SigningKey,
|
||||||
blobStore: blobStore,
|
repository: repo,
|
||||||
|
blobStore: blobStore,
|
||||||
},
|
},
|
||||||
schema2Handler: &schema2ManifestHandler{
|
schema2Handler: &schema2ManifestHandler{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
|
|
|
@ -21,8 +21,8 @@ var (
|
||||||
|
|
||||||
//schema2ManifestHandler is a ManifestHandler that covers schema2 manifests.
|
//schema2ManifestHandler is a ManifestHandler that covers schema2 manifests.
|
||||||
type schema2ManifestHandler struct {
|
type schema2ManifestHandler struct {
|
||||||
repository *repository
|
repository distribution.Repository
|
||||||
blobStore *linkedBlobStore
|
blobStore distribution.BlobStore
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,11 +62,6 @@ func (ms *schema2ManifestHandler) Put(ctx context.Context, manifest distribution
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Link the revision into the repository.
|
|
||||||
if err := ms.blobStore.linkBlob(ctx, revision); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return revision.Digest, nil
|
return revision.Digest, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,10 @@ import (
|
||||||
// signedManifestHandler is a ManifestHandler that covers schema1 manifests. It
|
// signedManifestHandler is a ManifestHandler that covers schema1 manifests. It
|
||||||
// can unmarshal and put schema1 manifests that have been signed by libtrust.
|
// can unmarshal and put schema1 manifests that have been signed by libtrust.
|
||||||
type signedManifestHandler struct {
|
type signedManifestHandler struct {
|
||||||
repository *repository
|
repository distribution.Repository
|
||||||
blobStore *linkedBlobStore
|
schema1SigningKey libtrust.PrivateKey
|
||||||
ctx context.Context
|
blobStore distribution.BlobStore
|
||||||
|
ctx context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ ManifestHandler = &signedManifestHandler{}
|
var _ ManifestHandler = &signedManifestHandler{}
|
||||||
|
@ -35,8 +36,8 @@ func (ms *signedManifestHandler) Unmarshal(ctx context.Context, dgst digest.Dige
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if ms.repository.schema1SigningKey != nil {
|
if ms.schema1SigningKey != nil {
|
||||||
if err := jsig.Sign(ms.repository.schema1SigningKey); err != nil {
|
if err := jsig.Sign(ms.schema1SigningKey); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,11 +76,6 @@ func (ms *signedManifestHandler) Put(ctx context.Context, manifest distribution.
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Link the revision into the repository.
|
|
||||||
if err := ms.blobStore.linkBlob(ctx, revision); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return revision.Digest, nil
|
return revision.Digest, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue