Support alternative media type format

Update `ExportedImageTar` media type detection to support `tar+gzip`
as well as `tar.gzip`. Recent updates to Docker Desktop appear to have
changed the format.

Fixes gh-43126
This commit is contained in:
Phillip Webb 2024-11-14 15:21:37 -08:00
parent a293560237
commit 25b6477aa8
3 changed files with 3 additions and 3 deletions

View File

@ -247,10 +247,10 @@ class ExportedImageTar implements Closeable {
}
private Compression getCompression(String mediaType) {
if (mediaType.endsWith(".tar.gzip")) {
if (mediaType.endsWith(".tar.gzip") || mediaType.endsWith(".tar+gzip")) {
return Compression.GZIP;
}
if (mediaType.endsWith(".tar.zstd")) {
if (mediaType.endsWith(".tar.zstd") || mediaType.endsWith(".tar+zstd")) {
return Compression.ZSTD;
}
return Compression.NONE;

View File

@ -38,7 +38,7 @@ class ExportedImageTarTests {
@ParameterizedTest
@ValueSource(strings = { "export-docker-desktop.tar", "export-docker-desktop-containerd.tar",
"export-docker-desktop-containerd-manifest-list.tar", "export-docker-engine.tar", "export-podman.tar",
"export-docker-desktop-nested-index.tar" })
"export-docker-desktop-nested-index.tar", "export-docker-desktop-containerd-alt-mediatype.tar" })
void test(String tarFile) throws Exception {
ImageReference reference = ImageReference.of("test:latest");
try (ExportedImageTar exportedImageTar = new ExportedImageTar(reference,