Skip to content

Commit 772add5

Browse files
committed
Fix DockerApiTests and fallback api version
Signed-off-by: hojooo <ghwn5833@gmail.com>
1 parent eeaab6d commit 772add5

File tree

2 files changed

+3
-37
lines changed
  • buildpack/spring-boot-buildpack-platform/src

2 files changed

+3
-37
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public Image pull(ImageReference reference, @Nullable ImagePlatform platform,
250250
String digest = digestCapture.getDigest();
251251
if (digest != null) {
252252
ImageReference digestRef = reference.withDigest(digest);
253-
return inspect(API_VERSION, digestRef);
253+
return inspect(PLATFORM_API_VERSION, digestRef);
254254
}
255255
}
256256
return inspect(API_VERSION, reference);

buildpack/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/DockerApiTests.java

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,7 @@ void pullWhenListenerIsNullThrowsException() {
207207
void pullPullsImageAndProducesEvents() throws Exception {
208208
ImageReference reference = ImageReference.of("docker.io/paketobuildpacks/builder:base");
209209
URI createUri = new URI(IMAGES_URL + "/create?fromImage=docker.io%2Fpaketobuildpacks%2Fbuilder%3Abase");
210-
URI imageUri = new URI(IMAGES_URL
211-
+ "/docker.io/paketobuildpacks/builder@sha256:4acb6bfd6c4f0cabaf7f3690e444afe51f1c7de54d51da7e63fac709c56f1c30/json");
210+
URI imageUri = new URI(IMAGES_URL + "/docker.io/paketobuildpacks/builder:base/json");
212211
given(http().post(eq(createUri), isNull())).willReturn(responseOf("pull-stream.json"));
213212
given(http().get(imageUri)).willReturn(responseOf("type/image.json"));
214213
Image image = this.api.pull(reference, null, this.pullListener);
@@ -223,8 +222,7 @@ void pullPullsImageAndProducesEvents() throws Exception {
223222
void pullWithRegistryAuthPullsImageAndProducesEvents() throws Exception {
224223
ImageReference reference = ImageReference.of("docker.io/paketobuildpacks/builder:base");
225224
URI createUri = new URI(IMAGES_URL + "/create?fromImage=docker.io%2Fpaketobuildpacks%2Fbuilder%3Abase");
226-
URI imageUri = new URI(IMAGES_URL
227-
+ "/docker.io/paketobuildpacks/builder@sha256:4acb6bfd6c4f0cabaf7f3690e444afe51f1c7de54d51da7e63fac709c56f1c30/json");
225+
URI imageUri = new URI(IMAGES_URL + "/docker.io/paketobuildpacks/builder:base/json");
228226
given(http().post(eq(createUri), eq("auth token"))).willReturn(responseOf("pull-stream.json"));
229227
given(http().get(imageUri)).willReturn(responseOf("type/image.json"));
230228
Image image = this.api.pull(reference, null, this.pullListener, "auth token");
@@ -450,38 +448,6 @@ void exportLayersWithSymlinksExportsLayerTars() throws Exception {
450448
.containsExactly("/cnb/stack.toml");
451449
}
452450

453-
@Test
454-
void exportLayersWithPlatformExportsLayerTars() throws Exception {
455-
ImageReference reference = ImageReference.of("docker.io/paketobuildpacks/builder:base");
456-
ImagePlatform platform = ImagePlatform.of("linux/amd64");
457-
URI exportUri = new URI(
458-
PLATFORM_IMAGES_URL + "/docker.io/paketobuildpacks/builder:base/get?platform=linux%2Famd64");
459-
given(DockerApiTests.this.http.head(eq(new URI(PING_URL))))
460-
.willReturn(responseWithHeaders(new BasicHeader(DockerApi.API_VERSION_HEADER_NAME, "1.41")));
461-
given(DockerApiTests.this.http.get(exportUri)).willReturn(responseOf("export.tar"));
462-
MultiValueMap<String, String> contents = new LinkedMultiValueMap<>();
463-
this.api.exportLayers(reference, platform, (name, archive) -> {
464-
ByteArrayOutputStream out = new ByteArrayOutputStream();
465-
archive.writeTo(out);
466-
try (TarArchiveInputStream in = new TarArchiveInputStream(
467-
new ByteArrayInputStream(out.toByteArray()))) {
468-
TarArchiveEntry entry = in.getNextEntry();
469-
while (entry != null) {
470-
contents.add(name, entry.getName());
471-
entry = in.getNextEntry();
472-
}
473-
}
474-
});
475-
assertThat(contents).hasSize(3)
476-
.containsKeys("70bb7a3115f3d5c01099852112c7e05bf593789e510468edb06b6a9a11fa3b73/layer.tar",
477-
"74a9a50ece13c025cf10e9110d9ddc86c995079c34e2a22a28d1a3d523222c6e/layer.tar",
478-
"a69532b5b92bb891fbd9fa1a6b3af9087ea7050255f59ba61a796f8555ecd783/layer.tar");
479-
assertThat(contents.get("70bb7a3115f3d5c01099852112c7e05bf593789e510468edb06b6a9a11fa3b73/layer.tar"))
480-
.containsExactly("/cnb/order.toml");
481-
assertThat(contents.get("74a9a50ece13c025cf10e9110d9ddc86c995079c34e2a22a28d1a3d523222c6e/layer.tar"))
482-
.containsExactly("/cnb/stack.toml");
483-
}
484-
485451
@Test
486452
void tagWhenReferenceIsNullThrowsException() {
487453
ImageReference tag = ImageReference.of("localhost:5000/ubuntu");

0 commit comments

Comments
 (0)