From 170f138e9c8c07c098252b1dc004148a9bc23f9c Mon Sep 17 00:00:00 2001 From: Aditya R Date: Tue, 8 Aug 2023 11:50:55 +0530 Subject: [PATCH] manifest: add support ForceCompressionFormat Implement https://github.com/containers/image/pull/2068 for libimage/manifest.Push Signed-off-by: Aditya R --- libimage/manifest_list.go | 1 + libimage/manifests/manifests.go | 2 ++ libimage/manifests/manifests_test.go | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/libimage/manifest_list.go b/libimage/manifest_list.go index 12586f2a4..8e688676a 100644 --- a/libimage/manifest_list.go +++ b/libimage/manifest_list.go @@ -461,6 +461,7 @@ func (m *ManifestList) Push(ctx context.Context, destination string, options *Ma SignSigstorePrivateKeyPassphrase: options.SignSigstorePrivateKeyPassphrase, RemoveSignatures: options.RemoveSignatures, ManifestType: options.ManifestMIMEType, + ForceCompressionFormat: options.ForceCompressionFormat, } _, d, err := m.list.Push(ctx, dest, pushOptions) diff --git a/libimage/manifests/manifests.go b/libimage/manifests/manifests.go index 68f991485..3c066e04b 100644 --- a/libimage/manifests/manifests.go +++ b/libimage/manifests/manifests.go @@ -72,6 +72,7 @@ type PushOptions struct { ManifestType string // the format to use when saving the list - possible options are oci, v2s1, and v2s2 SourceFilter LookupReferenceFunc // filter the list source AddCompression []string // add existing instances with requested compression algorithms to manifest list + ForceCompressionFormat bool // force push with requested compression ignoring the blobs which can be reused. } // Create creates a new list containing information about the specified image, @@ -259,6 +260,7 @@ func (l *list) Push(ctx context.Context, dest types.ImageReference, options Push SignSigstorePrivateKeyPassphrase: options.SignSigstorePrivateKeyPassphrase, ForceManifestMIMEType: singleImageManifestType, EnsureCompressionVariantsExist: compressionVariants, + ForceCompressionFormat: options.ForceCompressionFormat, } // Copy whatever we were asked to copy. diff --git a/libimage/manifests/manifests_test.go b/libimage/manifests/manifests_test.go index 06b5ba0b0..31dab04d9 100644 --- a/libimage/manifests/manifests_test.go +++ b/libimage/manifests/manifests_test.go @@ -337,4 +337,8 @@ func TestPush(t *testing.T) { options.AddCompression = []string{"zstd"} _, _, err = list.Push(ctx, destRef, options) assert.NoError(t, err, "list.Push(with replication for zstd specified)") + + options.ForceCompressionFormat = true + _, _, err = list.Push(ctx, destRef, options) + assert.NoError(t, err, "list.Push(with ForceCompressionFormat: true)") }