podman save: add --uncompressed

Add an option to `podman save` to allow uncompressed layers when
copying OCI images.  Do the neccessary plumbing for the remote client,
add tests and vendor in the latest commit from c/common to fetch
the neccessary changes in libimage.

Closes: #11613
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
Valentin Rothberg
2021-09-21 16:40:36 +02:00
parent e9214ce81e
commit 49c5688a30
17 changed files with 84 additions and 22 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.
@ -65,6 +70,8 @@ type CopyOptions struct {
// types. Short forms (e.g., oci, v2s2) used by some tools are not
// supported.
ManifestMIMEType string
// Accept uncompressed layers when copying OCI images.
OciAcceptUncompressedLayers bool
// If OciEncryptConfig is non-nil, it indicates that an image should be
// encrypted. The encryption options is derived from the construction
// of EncryptConfig object. Note: During initial encryption process of
@ -242,6 +249,17 @@ 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
}
// NOTE: for the sake of consistency it's called Oci* in the CopyOptions.
c.systemContext.OCIAcceptUncompressedLayers = options.OciAcceptUncompressedLayers
policy, err := signature.DefaultPolicy(c.systemContext)
if err != nil {
return nil, err