Skip to content

Commit 1ff9c5b

Browse files
committed
Fix exportLayers to use JSON-encoded platform format
Signed-off-by: hojooo <ghwn5833@gmail.com>
1 parent 174fdb3 commit 1ff9c5b

File tree

1 file changed

+13
-15
lines changed
  • buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker

1 file changed

+13
-15
lines changed

buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/DockerApi.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public class DockerApi {
6868

6969
static final ApiVersion PLATFORM_API_VERSION = ApiVersion.of(1, 41);
7070

71-
static final ApiVersion INSPECT_PLATFORM_API_VERSION = ApiVersion.of(1, 49);
71+
static final ApiVersion EXPORT_PLATFORM_API_VERSION = ApiVersion.of(1, 48);
7272

73-
static final ApiVersion EXPORT_PLATFORM_API_VERSION = ApiVersion.of(1, 51);
73+
static final ApiVersion INSPECT_PLATFORM_API_VERSION = ApiVersion.of(1, 49);
7474

7575
static final ApiVersion UNKNOWN_API_VERSION = ApiVersion.of(0, 0);
7676

@@ -243,12 +243,17 @@ public Image pull(ImageReference reference, @Nullable ImagePlatform platform,
243243
listener.onUpdate(event);
244244
});
245245
}
246-
ApiVersion callVersion = API_VERSION;
247246
if (platform != null) {
248-
callVersion = (getApiVersion().supports(INSPECT_PLATFORM_API_VERSION))
249-
? INSPECT_PLATFORM_API_VERSION : PLATFORM_API_VERSION;
247+
if (getApiVersion().supports(INSPECT_PLATFORM_API_VERSION)) {
248+
return inspect(INSPECT_PLATFORM_API_VERSION, reference, platform);
249+
}
250+
String digest = digestCapture.getDigest();
251+
if (digest != null) {
252+
ImageReference digestRef = reference.withDigest(digest);
253+
return inspect(API_VERSION, digestRef);
254+
}
250255
}
251-
return inspect(callVersion, reference, platform);
256+
return inspect(API_VERSION, reference);
252257
}
253258
finally {
254259
listener.onFinish();
@@ -335,19 +340,12 @@ public void exportLayers(ImageReference reference, @Nullable ImagePlatform platf
335340
IOBiConsumer<String, TarArchive> exports) throws IOException {
336341
Assert.notNull(reference, "'reference' must not be null");
337342
Assert.notNull(exports, "'exports' must not be null");
338-
URI uri;
343+
URI uri = buildUrl("/images/" + reference + "/get");
339344
if (platform != null) {
340345
if (getApiVersion().supports(EXPORT_PLATFORM_API_VERSION)) {
341346
uri = buildUrl(EXPORT_PLATFORM_API_VERSION, "/images/" + reference + "/get", "platform",
342-
platform.toString());
347+
platform.toQueryParameter(getApiVersion()));
343348
}
344-
else {
345-
// Platform selection for /images/{ref}/get is supported from 1.51
346-
uri = buildUrl("/images/" + reference + "/get");
347-
}
348-
}
349-
else {
350-
uri = buildUrl("/images/" + reference + "/get");
351349
}
352350
try (Response response = http().get(uri)) {
353351
try (ExportedImageTar exportedImageTar = new ExportedImageTar(reference, response.getContent())) {

0 commit comments

Comments
 (0)