Merge pull request #778 from giuseppe/copier-accept-compression

libimage: accept CompressionFormat/CompressionLevel
This commit is contained in:
OpenShift Merge Robot 2021-09-21 03:35:37 -04:00 committed by GitHub
commit c42a32358c
1 changed files with 13 additions and 0 deletions

View File

@ -12,6 +12,7 @@ import (
"github.com/containers/common/pkg/retry"
"github.com/containers/image/v5/copy"
"github.com/containers/image/v5/docker/reference"
"github.com/containers/image/v5/pkg/compression"
"github.com/containers/image/v5/signature"
storageTransport "github.com/containers/image/v5/storage"
"github.com/containers/image/v5/types"
@ -40,6 +41,10 @@ type CopyOptions struct {
// Allows for customizing the destination reference lookup. This can
// be used to use custom blob caches.
DestinationLookupReferenceFunc LookupReferenceFunc
// CompressionFormat is the format to use for the compression of the blobs
CompressionFormat *compression.Algorithm
// CompressionLevel specifies what compression level is used
CompressionLevel *int
// containers-auth.json(5) file to use when authenticating against
// container registries.
@ -242,6 +247,14 @@ func (r *Runtime) newCopier(options *CopyOptions) (*copier, error) {
c.systemContext.DockerCertPath = options.CertDirPath
}
if options.CompressionFormat != nil {
c.systemContext.CompressionFormat = options.CompressionFormat
}
if options.CompressionLevel != nil {
c.systemContext.CompressionLevel = options.CompressionLevel
}
policy, err := signature.DefaultPolicy(c.systemContext)
if err != nil {
return nil, err