Adds functional options arguments to the Blobs Create method
Removes the Mount operation and instead implements this behavior as part of Create a From option is provided, which in turn returns a rich ErrBlobMounted indicating that a blob upload session was not initiated, but instead the blob was mounted from another repository Signed-off-by: Brian Bland <brian.bland@docker.com>
This commit is contained in:
parent
4378e1aa85
commit
ce88d8a6f4
13 changed files with 217 additions and 120 deletions
|
@ -160,8 +160,15 @@ func (bsl *blobServiceListener) Put(ctx context.Context, mediaType string, p []b
|
|||
return desc, err
|
||||
}
|
||||
|
||||
func (bsl *blobServiceListener) Create(ctx context.Context) (distribution.BlobWriter, error) {
|
||||
wr, err := bsl.BlobStore.Create(ctx)
|
||||
func (bsl *blobServiceListener) Create(ctx context.Context, options ...distribution.BlobCreateOption) (distribution.BlobWriter, error) {
|
||||
wr, err := bsl.BlobStore.Create(ctx, options...)
|
||||
switch err := err.(type) {
|
||||
case distribution.ErrBlobMounted:
|
||||
if err := bsl.parent.listener.BlobMounted(bsl.parent.Repository.Name(), err.Descriptor, err.From.Name()); err != nil {
|
||||
context.GetLogger(ctx).Errorf("error dispatching blob mount to listener: %v", err)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return bsl.decorateWriter(wr), err
|
||||
}
|
||||
|
||||
|
@ -170,17 +177,6 @@ func (bsl *blobServiceListener) Resume(ctx context.Context, id string) (distribu
|
|||
return bsl.decorateWriter(wr), err
|
||||
}
|
||||
|
||||
func (bsl *blobServiceListener) Mount(ctx context.Context, sourceRepo string, dgst digest.Digest) (distribution.Descriptor, error) {
|
||||
desc, err := bsl.BlobStore.Mount(ctx, sourceRepo, dgst)
|
||||
if err == nil {
|
||||
if err := bsl.parent.listener.BlobMounted(bsl.parent.Repository.Name(), desc, sourceRepo); err != nil {
|
||||
context.GetLogger(ctx).Errorf("error dispatching layer mount to listener: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
return desc, err
|
||||
}
|
||||
|
||||
func (bsl *blobServiceListener) decorateWriter(wr distribution.BlobWriter) distribution.BlobWriter {
|
||||
return &blobWriterListener{
|
||||
BlobWriter: wr,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue