Skip to content

Commit

Permalink
copy: make using partial blobs configurable
Browse files Browse the repository at this point in the history
Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Nov 26, 2020
1 parent c26c359 commit 393baa8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions copy/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ type copier struct {
compressionLevel *int
ociDecryptConfig *encconfig.DecryptConfig
ociEncryptConfig *encconfig.EncryptConfig
fetchPartialBlobs bool
}

// imageCopier tracks state specific to a single image (possibly an item of a manifest list)
Expand Down Expand Up @@ -182,6 +183,8 @@ type Options struct {
// OciDecryptConfig contains the config that can be used to decrypt an image if it is
// encrypted if non-nil. If nil, it does not attempt to decrypt an image.
OciDecryptConfig *encconfig.DecryptConfig

FetchPartialBlobs bool // attempt to fetch the blob partially. Experimental.
}

// validateImageListSelection returns an error if the passed-in value is not one that we recognize as a valid ImageListSelection value
Expand Down Expand Up @@ -257,9 +260,10 @@ func Image(ctx context.Context, policyContext *signature.PolicyContext, destRef,
// FIXME? The cache is used for sources and destinations equally, but we only have a SourceCtx and DestinationCtx.
// For now, use DestinationCtx (because blob reuse changes the behavior of the destination side more); eventually
// we might want to add a separate CommonCtx — or would that be too confusing?
blobInfoCache: blobinfocache.DefaultCache(options.DestinationCtx),
ociDecryptConfig: options.OciDecryptConfig,
ociEncryptConfig: options.OciEncryptConfig,
blobInfoCache: blobinfocache.DefaultCache(options.DestinationCtx),
ociDecryptConfig: options.OciDecryptConfig,
ociEncryptConfig: options.OciEncryptConfig,
fetchPartialBlobs: options.FetchPartialBlobs,
}
// Default to using gzip compression unless specified otherwise.
if options.DestinationCtx == nil || options.DestinationCtx.CompressionFormat == nil {
Expand Down Expand Up @@ -1135,7 +1139,7 @@ func (ic *imageCopier) copyLayer(ctx context.Context, srcInfo types.BlobInfo, to

imgSource, okSource := ic.c.rawSource.(types.ImageSourceSeekable)
imgDest, okDest := ic.c.dest.(types.ImageDestinationPartial)
if okSource && okDest && !diffIDIsNeeded {
if ic.c.fetchPartialBlobs && okSource && okDest && !diffIDIsNeeded {
bar := ic.c.createProgressBar(pool, true, srcInfo, "blob", "done")

progress := make(chan int64)
Expand Down

0 comments on commit 393baa8

Please sign in to comment.