mirror of
https://github.com/containers/image.git
synced 2025-04-18 19:44:05 +03:00
Try all manifest formats if the destinations accepts all of them
We might want to trigger a conversion to OCI if the source is not OCI, but the destination already contains a Zstd version of a layer. We can do that for destinations that express a restricted list of manifest formats, so it is unexpected that completely unrestricted destinations can't trigger a conversion, and just fail (right now), or perhaps don't fail but unnecessarily upload (in the future), in that case. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
parent
ffdc507d89
commit
c438c69057
@ -85,13 +85,6 @@ func determineManifestConversion(in determineManifestConversionInputs) (manifest
|
||||
|
||||
restrictiveCompressionRequired := in.requestedCompressionFormat != nil && !internalManifest.CompressionAlgorithmIsUniversallySupported(*in.requestedCompressionFormat)
|
||||
if len(destSupportedManifestMIMETypes) == 0 {
|
||||
if (!in.requiresOCIEncryption || manifest.MIMETypeSupportsEncryption(srcType)) &&
|
||||
(!restrictiveCompressionRequired || internalManifest.MIMETypeSupportsCompressionAlgorithm(srcType, *in.requestedCompressionFormat)) {
|
||||
return manifestConversionPlan{ // Anything goes; just use the original as is, do not try any conversions.
|
||||
preferredMIMEType: srcType,
|
||||
otherMIMETypeCandidates: []string{},
|
||||
}, nil
|
||||
}
|
||||
destSupportedManifestMIMETypes = allManifestMIMETypes
|
||||
}
|
||||
supportedByDest := set.New[string]()
|
||||
|
@ -56,13 +56,13 @@ func TestDetermineManifestConversion(t *testing.T) {
|
||||
destTypes []string
|
||||
expected manifestConversionPlan
|
||||
}{
|
||||
// Destination accepts anything — no conversion necessary
|
||||
// Destination accepts anything — consider all options, prefer the source format
|
||||
{
|
||||
"s1→anything", manifest.DockerV2Schema1SignedMediaType, nil,
|
||||
manifestConversionPlan{
|
||||
preferredMIMEType: manifest.DockerV2Schema1SignedMediaType,
|
||||
preferredMIMETypeNeedsConversion: false,
|
||||
otherMIMETypeCandidates: []string{},
|
||||
otherMIMETypeCandidates: []string{manifest.DockerV2Schema2MediaType, v1.MediaTypeImageManifest, manifest.DockerV2Schema1MediaType},
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -70,7 +70,7 @@ func TestDetermineManifestConversion(t *testing.T) {
|
||||
manifestConversionPlan{
|
||||
preferredMIMEType: manifest.DockerV2Schema2MediaType,
|
||||
preferredMIMETypeNeedsConversion: false,
|
||||
otherMIMETypeCandidates: []string{},
|
||||
otherMIMETypeCandidates: []string{manifest.DockerV2Schema1SignedMediaType, v1.MediaTypeImageManifest, manifest.DockerV2Schema1MediaType},
|
||||
},
|
||||
},
|
||||
// Destination accepts the unmodified original
|
||||
|
Loading…
x
Reference in New Issue
Block a user