mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Add support for CNB platform API 0.9
Fixes gh-30566
This commit is contained in:
parent
ff40c8b6f5
commit
f032690d0a
@ -17,8 +17,7 @@
|
||||
package org.springframework.boot.buildpack.platform.build;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@ -32,8 +31,7 @@ final class ApiVersions {
|
||||
/**
|
||||
* The platform API versions supported by this release.
|
||||
*/
|
||||
static final ApiVersions SUPPORTED_PLATFORMS = new ApiVersions(ApiVersion.of(0, 3), ApiVersion.of(0, 4),
|
||||
ApiVersion.of(0, 5), ApiVersion.of(0, 6), ApiVersion.of(0, 7), ApiVersion.of(0, 8));
|
||||
static final ApiVersions SUPPORTED_PLATFORMS = ApiVersions.of(0, IntStream.rangeClosed(3, 9));
|
||||
|
||||
private final ApiVersion[] apiVersions;
|
||||
|
||||
@ -92,8 +90,12 @@ final class ApiVersions {
|
||||
* @throws IllegalArgumentException if any values could not be parsed
|
||||
*/
|
||||
static ApiVersions parse(String... values) {
|
||||
List<ApiVersion> versions = Arrays.stream(values).map(ApiVersion::parse).collect(Collectors.toList());
|
||||
return new ApiVersions(versions.toArray(new ApiVersion[] {}));
|
||||
return new ApiVersions(Arrays.stream(values).map(ApiVersion::parse).toArray(ApiVersion[]::new));
|
||||
}
|
||||
|
||||
static ApiVersions of(int major, IntStream minorsInclusive) {
|
||||
return new ApiVersions(
|
||||
minorsInclusive.mapToObj((minor) -> ApiVersion.of(major, minor)).toArray(ApiVersion[]::new));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.boot.buildpack.platform.build;
|
||||
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@ -65,6 +67,12 @@ class ApiVersionsTests {
|
||||
"Detected platform API versions '1.3,1.4' are not included in supported versions '1.1,1.2'");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createFromRange() {
|
||||
ApiVersions versions = ApiVersions.of(1, IntStream.rangeClosed(2, 7));
|
||||
assertThat(versions.toString()).isEqualTo("1.2,1.3,1.4,1.5,1.6,1.7");
|
||||
}
|
||||
|
||||
@Test
|
||||
void toStringReturnsString() {
|
||||
assertThat(ApiVersions.parse("1.1", "2.2", "3.3").toString()).isEqualTo("1.1,2.2,3.3");
|
||||
|
@ -161,8 +161,8 @@ class LifecycleTests {
|
||||
given(this.docker.container().create(any(), any())).willAnswer(answerWithGeneratedContainerId());
|
||||
given(this.docker.container().wait(any())).willReturn(ContainerStatus.of(0, null));
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> createLifecycle("builder-metadata-unsupported-api.json").execute()).withMessage(
|
||||
"Detected platform API versions '0.2' are not included in supported versions '0.3,0.4,0.5,0.6,0.7,0.8'");
|
||||
.isThrownBy(() -> createLifecycle("builder-metadata-unsupported-api.json").execute())
|
||||
.withMessageContaining("Detected platform API versions '0.2' are not included in supported versions");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -171,8 +171,9 @@ class LifecycleTests {
|
||||
given(this.docker.container().create(any(), any())).willAnswer(answerWithGeneratedContainerId());
|
||||
given(this.docker.container().wait(any())).willReturn(ContainerStatus.of(0, null));
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> createLifecycle("builder-metadata-unsupported-apis.json").execute()).withMessage(
|
||||
"Detected platform API versions '0.1,0.2' are not included in supported versions '0.3,0.4,0.5,0.6,0.7,0.8'");
|
||||
.isThrownBy(() -> createLifecycle("builder-metadata-unsupported-apis.json").execute())
|
||||
.withMessageContaining(
|
||||
"Detected platform API versions '0.1,0.2' are not included in supported versions");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user