Remove APIs deprecated for removal in 3.5

Closes gh-43788
This commit is contained in:
Andy Wilkinson
2025-01-14 12:34:43 +00:00
parent f301b2a123
commit 2f29a49a1d
61 changed files with 29 additions and 3522 deletions

View File

@@ -17,11 +17,8 @@
package org.springframework.boot.buildpack.platform.docker;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -293,34 +290,6 @@ public class DockerApi {
}
}
/**
* Export the layers of an image as paths to layer tar files.
* @param reference the reference to export
* @param exports a consumer to receive the layer tar file paths (file can only be
* accessed during the callback)
* @throws IOException on IO error
* @since 2.7.10
* @deprecated since 3.2.6 for removal in 3.5.0 in favor of
* {@link #exportLayers(ImageReference, IOBiConsumer)}
*/
@Deprecated(since = "3.2.6", forRemoval = true)
public void exportLayerFiles(ImageReference reference, IOBiConsumer<String, Path> exports) throws IOException {
Assert.notNull(reference, "'reference' must not be null");
Assert.notNull(exports, "'exports' must not be null");
exportLayers(reference, (name, archive) -> {
Path path = Files.createTempFile("docker-export-layer-files-", null);
try {
try (OutputStream out = Files.newOutputStream(path)) {
archive.writeTo(out);
exports.accept(name, path);
}
}
finally {
Files.delete(path);
}
});
}
/**
* Export the layers of an image as {@link TarArchive TarArchives}.
* @param reference the reference to export

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -78,28 +78,6 @@ public abstract class ProgressUpdateEvent extends UpdateEvent {
this.total = total;
}
/**
* Return the current progress value.
* @return the current progress
* @deprecated since 3.3.7 for removal in 3.5.0 in favor of
* {@link #asPercentage()}
*/
@Deprecated(since = "3.3.7", forRemoval = true)
public int getCurrent() {
return (int) Long.min(this.current, Integer.MAX_VALUE);
}
/**
* Return the total progress possible value.
* @return the total progress possible
* @deprecated since 3.3.7 for removal in 3.5.0 in favor of
* {@link #asPercentage()}
*/
@Deprecated(since = "3.3.7", forRemoval = true)
public int getTotal() {
return (int) Long.min(this.total, Integer.MAX_VALUE);
}
/**
* Return the progress as a percentage.
* @return the progress percentage
@@ -110,14 +88,7 @@ public abstract class ProgressUpdateEvent extends UpdateEvent {
return (percentage < 0) ? 0 : Math.min(percentage, 100);
}
/**
* Return if the progress detail is considered empty.
* @param progressDetail the progress detail to check
* @return if the progress detail is empty
* @deprecated since 3.3.7 for removal in 3.5.0
*/
@Deprecated(since = "3.3.7", forRemoval = true)
public static boolean isEmpty(ProgressDetail progressDetail) {
private static boolean isEmpty(ProgressDetail progressDetail) {
return progressDetail == null || progressDetail.current == null || progressDetail.total == null;
}

View File

@@ -23,10 +23,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
@@ -392,21 +389,6 @@ class DockerApiTests {
assertThat(image.getLayers()).hasSize(46);
}
@Test
@SuppressWarnings("removal")
void exportLayersWhenReferenceIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.api.exportLayerFiles(null, (name, archive) -> {
})).withMessage("'reference' must not be null");
}
@Test
@SuppressWarnings("removal")
void exportLayersWhenExportsIsNullThrowsException() {
ImageReference reference = ImageReference.of("gcr.io/paketo-buildpacks/builder:base");
assertThatIllegalArgumentException().isThrownBy(() -> this.api.exportLayerFiles(reference, null))
.withMessage("'exports' must not be null");
}
@Test
void exportLayersExportsLayerTars() throws Exception {
ImageReference reference = ImageReference.of("gcr.io/paketo-buildpacks/builder:base");
@@ -463,29 +445,6 @@ class DockerApiTests {
.containsExactly("/cnb/stack.toml");
}
@Test
@SuppressWarnings("removal")
void exportLayerFilesDeletesTempFiles() throws Exception {
ImageReference reference = ImageReference.of("gcr.io/paketo-buildpacks/builder:base");
URI exportUri = new URI(IMAGES_URL + "/gcr.io/paketo-buildpacks/builder:base/get");
given(DockerApiTests.this.http.get(exportUri)).willReturn(responseOf("export.tar"));
List<Path> layerFilePaths = new ArrayList<>();
this.api.exportLayerFiles(reference, (name, path) -> layerFilePaths.add(path));
layerFilePaths.forEach((path) -> assertThat(path.toFile()).doesNotExist());
}
@Test
@SuppressWarnings("removal")
void exportLayersWithNoManifestThrowsException() throws Exception {
ImageReference reference = ImageReference.of("gcr.io/paketo-buildpacks/builder:base");
URI exportUri = new URI(IMAGES_URL + "/gcr.io/paketo-buildpacks/builder:base/get");
given(DockerApiTests.this.http.get(exportUri)).willReturn(responseOf("export-no-manifest.tar"));
String expectedMessage = "Exported image '%s' does not contain 'index.json' or 'manifest.json'"
.formatted(reference);
assertThatIllegalStateException().isThrownBy(() -> this.api.exportLayerFiles(reference, (name, archive) -> {
})).withMessageContaining(expectedMessage);
}
@Test
void tagWhenReferenceIsNullThrowsException() {
ImageReference tag = ImageReference.of("localhost:5000/ubuntu");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,20 +39,14 @@ abstract class ProgressUpdateEventTests<E extends ProgressUpdateEvent> {
}
@Test
@SuppressWarnings("removal")
void getProgressDetailsReturnsProgressDetails() {
ProgressUpdateEvent event = createEvent();
assertThat(event.getProgressDetail().getCurrent()).isOne();
assertThat(event.getProgressDetail().getTotal()).isEqualTo(2);
assertThat(event.getProgressDetail().asPercentage()).isEqualTo(50);
}
@Test
@SuppressWarnings("removal")
void getProgressDetailsReturnsProgressDetailsForLongNumbers() {
ProgressUpdateEvent event = createEvent("status", new ProgressDetail(4000000000L, 8000000000L), "progress");
assertThat(event.getProgressDetail().getCurrent()).isEqualTo(Integer.MAX_VALUE);
assertThat(event.getProgressDetail().getTotal()).isEqualTo(Integer.MAX_VALUE);
assertThat(event.getProgressDetail().asPercentage()).isEqualTo(50);
}
@@ -62,27 +56,6 @@ abstract class ProgressUpdateEventTests<E extends ProgressUpdateEvent> {
assertThat(event.getProgress()).isEqualTo("progress");
}
@Test
@SuppressWarnings("removal")
void progressDetailIsEmptyWhenCurrentIsNullReturnsTrue() {
ProgressDetail detail = new ProgressDetail(null, 2L);
assertThat(ProgressDetail.isEmpty(detail)).isTrue();
}
@Test
@SuppressWarnings("removal")
void progressDetailIsEmptyWhenTotalIsNullReturnsTrue() {
ProgressDetail detail = new ProgressDetail(1L, null);
assertThat(ProgressDetail.isEmpty(detail)).isTrue();
}
@Test
@SuppressWarnings("removal")
void progressDetailIsEmptyWhenTotalAndCurrentAreNotNullReturnsFalse() {
ProgressDetail detail = new ProgressDetail(1L, 2L);
assertThat(ProgressDetail.isEmpty(detail)).isFalse();
}
protected E createEvent() {
return createEvent("status", new ProgressDetail(1L, 2L), "progress");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,8 +36,6 @@ class PullUpdateEventTests extends AbstractJsonTests {
PullImageUpdateEvent.class);
assertThat(event.getId()).isEqualTo("4f4fb700ef54");
assertThat(event.getStatus()).isEqualTo("Extracting");
assertThat(event.getProgressDetail().getCurrent()).isEqualTo(16);
assertThat(event.getProgressDetail().getTotal()).isEqualTo(32);
assertThat(event.getProgressDetail().asPercentage()).isEqualTo(50);
assertThat(event.getProgress()).isEqualTo("[==================================================>] 32B/32B");
}