Browse Source

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
3.2.x
Phillip Webb 1 year ago
parent
commit
25b6477aa8
  1. 4
      spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/ExportedImageTar.java
  2. 2
      spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/ExportedImageTarTests.java
  3. BIN
      spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/docker/export-docker-desktop-containerd-alt-mediatype.tar

4
spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/ExportedImageTar.java

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

2
spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/ExportedImageTarTests.java

@ -38,7 +38,7 @@ class ExportedImageTarTests {
@ParameterizedTest @ParameterizedTest
@ValueSource(strings = { "export-docker-desktop.tar", "export-docker-desktop-containerd.tar", @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-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 { void test(String tarFile) throws Exception {
ImageReference reference = ImageReference.of("test:latest"); ImageReference reference = ImageReference.of("test:latest");
try (ExportedImageTar exportedImageTar = new ExportedImageTar(reference, try (ExportedImageTar exportedImageTar = new ExportedImageTar(reference,

BIN
spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/docker/export-docker-desktop-containerd-alt-mediatype.tar

Binary file not shown.
Loading…
Cancel
Save