From 58b84676d0c1c5334bbc0bb34ea00b2e0e7c83fe Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Thu, 12 Jul 2018 16:24:16 +0530 Subject: [PATCH] Issue #475 Add flag for image compress layer for oci destination Signed-off-by: Praveen Kumar --- .gitignore | 3 +++ oci/layout/oci_dest.go | 11 ++++++++--- types/types.go | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index a085e431..3f7bdaa0 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ tools.timestamp # Visual Studio Code .vscode/* + +# trash +trash.lock diff --git a/oci/layout/oci_dest.go b/oci/layout/oci_dest.go index 0a0cad15..35163275 100644 --- a/oci/layout/oci_dest.go +++ b/oci/layout/oci_dest.go @@ -18,9 +18,10 @@ import ( ) type ociImageDestination struct { - ref ociReference - index imgspecv1.Index - sharedBlobDir string + ref ociReference + index imgspecv1.Index + sharedBlobDir string + acceptUncompressedLayers bool } // newImageDestination returns an ImageDestination for writing to an existing directory. @@ -43,6 +44,7 @@ func newImageDestination(sys *types.SystemContext, ref ociReference) (types.Imag d := &ociImageDestination{ref: ref, index: *index} if sys != nil { d.sharedBlobDir = sys.OCISharedBlobDirPath + d.acceptUncompressedLayers = sys.OCIAcceptUncompressedLayers } if err := ensureDirectoryExists(d.ref.dir); err != nil { @@ -81,6 +83,9 @@ func (d *ociImageDestination) SupportsSignatures(ctx context.Context) error { } func (d *ociImageDestination) DesiredLayerCompression() types.LayerCompression { + if d.acceptUncompressedLayers { + return types.PreserveOriginal + } return types.Compress } diff --git a/types/types.go b/types/types.go index 3ec77e0d..5d05b711 100644 --- a/types/types.go +++ b/types/types.go @@ -364,6 +364,8 @@ type SystemContext struct { OCIInsecureSkipTLSVerify bool // If not "", use a shared directory for storing blobs rather than within OCI layouts OCISharedBlobDirPath string + // Allow UnCompress image layer for OCI image layer + OCIAcceptUncompressedLayers bool // === docker.Transport overrides === // If not "", a directory containing a CA certificate (ending with ".crt"),