Skip to content

Commit

Permalink
manifest: add support ForceCompressionFormat
Browse files Browse the repository at this point in the history
Implement containers/image#2068 for
libimage/manifest.Push

Signed-off-by: Aditya R <[email protected]>
  • Loading branch information
flouthoc committed Aug 8, 2023
1 parent 6da326e commit 02bf3bc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions libimage/manifest_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions libimage/manifests/manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions libimage/manifests/manifests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
}

0 comments on commit 02bf3bc

Please sign in to comment.