Merge branch '2.7.x'

pull/28887/head
Scott Frederick 3 years ago
commit 1f838bf2ee

@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 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.
@ -73,7 +73,7 @@ final class ApiVersion {
* the same version number. A 1.x or higher release matches when the versions have the
* same major version and a minor that is equal or greater.
* @param other the version to check against
* @return if the specified API is supported
* @return if the specified API version is supported
* @see #assertSupports(ApiVersion)
*/
boolean supports(ApiVersion other) {
@ -86,6 +86,21 @@ final class ApiVersion {
return this.minor >= other.minor;
}
/**
* Returns if this API version supports any of the given versions.
* @param others the versions to check against
* @return if any of the specified API versions are supported
* @see #supports(ApiVersion)
*/
boolean supportsAny(ApiVersion... others) {
for (ApiVersion other : others) {
if (supports(other)) {
return true;
}
}
return false;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {

@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 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.
@ -32,7 +32,8 @@ 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));
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));
private final ApiVersion[] apiVersions;

@ -181,7 +181,7 @@ class Lifecycle implements Closeable {
}
private boolean requiresProcessTypeDefault() {
return this.platformVersion.supports(ApiVersion.of(0, 4));
return this.platformVersion.supportsAny(ApiVersion.of(0, 4), ApiVersion.of(0, 5));
}
private void run(Phase phase) throws IOException {

@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 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.
@ -16,6 +16,8 @@
package org.springframework.boot.buildpack.platform.build;
import java.util.Arrays;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@ -68,7 +70,7 @@ class ApiVersionTests {
}
@Test
void supportWhenSame() {
void supportsWhenSame() {
assertThat(supports("0.0", "0.0")).isTrue();
assertThat(supports("0.1", "0.1")).isTrue();
assertThat(supports("1.0", "1.0")).isTrue();
@ -92,11 +94,21 @@ class ApiVersionTests {
}
@Test
void supportWhenMajorZeroAndDifferentMinor() {
void supportsWhenMajorZeroAndDifferentMinor() {
assertThat(supports("0.2", "0.1")).isFalse();
assertThat(supports("0.2", "0.3")).isFalse();
}
@Test
void supportsAnyWhenOneMatches() {
assertThat(supportsAny("0.2", "0.1", "0.2")).isTrue();
}
@Test
void supportsAnyWhenNoneMatch() {
assertThat(supportsAny("0.2", "0.3", "0.4")).isFalse();
}
@Test
void toStringReturnsString() {
assertThat(ApiVersion.parse("1.2").toString()).isEqualTo("1.2");
@ -115,4 +127,9 @@ class ApiVersionTests {
return ApiVersion.parse(v1).supports(ApiVersion.parse(v2));
}
private boolean supportsAny(String v1, String... others) {
return ApiVersion.parse(v1)
.supportsAny(Arrays.stream(others).map(ApiVersion::parse).toArray(ApiVersion[]::new));
}
}

@ -92,7 +92,7 @@ class BuilderMetadataTests extends AbstractJsonTests {
assertThat(metadata.getStack().getRunImage().getMirrors()).isEmpty();
assertThat(metadata.getLifecycle().getVersion()).isEqualTo("0.7.2");
assertThat(metadata.getLifecycle().getApi().getBuildpack()).isEqualTo("0.2");
assertThat(metadata.getLifecycle().getApi().getPlatform()).isEqualTo("0.4");
assertThat(metadata.getLifecycle().getApi().getPlatform()).isEqualTo("0.8");
assertThat(metadata.getLifecycle().getApis().getBuildpack()).isNull();
assertThat(metadata.getLifecycle().getApis().getPlatform()).isNull();
}
@ -102,9 +102,10 @@ class BuilderMetadataTests extends AbstractJsonTests {
BuilderMetadata metadata = BuilderMetadata.fromJson(getContentAsString("builder-metadata-supported-apis.json"));
assertThat(metadata.getLifecycle().getVersion()).isEqualTo("0.7.2");
assertThat(metadata.getLifecycle().getApi().getBuildpack()).isEqualTo("0.2");
assertThat(metadata.getLifecycle().getApi().getPlatform()).isEqualTo("0.4");
assertThat(metadata.getLifecycle().getApi().getPlatform()).isEqualTo("0.8");
assertThat(metadata.getLifecycle().getApis().getBuildpack()).containsExactly("0.1", "0.2", "0.3");
assertThat(metadata.getLifecycle().getApis().getPlatform()).containsExactly("0.3", "0.4");
assertThat(metadata.getLifecycle().getApis().getPlatform()).containsExactly("0.3", "0.4", "0.5", "0.6", "0.7",
"0.8");
}
@Test

@ -159,8 +159,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'");
.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'");
}
@Test
@ -170,7 +170,7 @@ class LifecycleTests {
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.5,0.6' are not included in supported versions '0.3,0.4'");
"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'");
}
@Test

@ -16,7 +16,7 @@
"version": "0.7.2",
"api": {
"buildpack": "0.2",
"platform": "0.4"
"platform": "0.8"
},
"apis": {
"buildpack": {
@ -30,9 +30,13 @@
"platform": {
"deprecated": [],
"supported": [
"0.3",
"0.4"
]
"0.3",
"0.4",
"0.5",
"0.6",
"0.7",
"0.8"
]
}
}
},

@ -182,7 +182,7 @@
"version": "0.7.2",
"api": {
"buildpack": "0.2",
"platform": "0.4"
"platform": "0.8"
}
},
"createdBy": {

@ -1,12 +1,38 @@
{
"User" : "root",
"Image" : "pack.local/ephemeral-builder",
"Cmd" : [ "/cnb/lifecycle/creator", "-app", "/workspace", "-platform", "/platform", "-run-image", "docker.io/cloudfoundry/run:latest", "-layers", "/layers", "-cache-dir", "/cache", "-launch-cache", "/launch-cache", "-daemon", "-process-type=web", "docker.io/library/my-application:latest" ],
"Env" : [ "CNB_PLATFORM_API=0.4" ],
"Labels" : {
"author" : "spring-boot"
"User": "root",
"Image": "pack.local/ephemeral-builder",
"Cmd": [
"/cnb/lifecycle/creator",
"-app",
"/workspace",
"-platform",
"/platform",
"-run-image",
"docker.io/cloudfoundry/run:latest",
"-layers",
"/layers",
"-cache-dir",
"/cache",
"-launch-cache",
"/launch-cache",
"-daemon",
"docker.io/library/my-application:latest"
],
"Env": [
"CNB_PLATFORM_API=0.8"
],
"Labels": {
"author": "spring-boot"
},
"HostConfig" : {
"Binds" : [ "/var/run/docker.sock:/var/run/docker.sock", "pack-layers-aaaaaaaaaa:/layers", "pack-app-aaaaaaaaaa:/workspace", "pack-cache-b35197ac41ea.build:/cache", "pack-cache-b35197ac41ea.launch:/launch-cache", "/host/src/path:/container/dest/path:ro", "volume-name:/container/volume/path:rw" ]
"HostConfig": {
"Binds": [
"/var/run/docker.sock:/var/run/docker.sock",
"pack-layers-aaaaaaaaaa:/layers",
"pack-app-aaaaaaaaaa:/workspace",
"pack-cache-b35197ac41ea.build:/cache",
"pack-cache-b35197ac41ea.launch:/launch-cache",
"/host/src/path:/container/dest/path:ro",
"volume-name:/container/volume/path:rw"
]
}
}

@ -16,11 +16,10 @@
"-launch-cache",
"/launch-cache",
"-daemon",
"-process-type=web",
"docker.io/library/my-application:latest"
],
"Env": [
"CNB_PLATFORM_API=0.4"
"CNB_PLATFORM_API=0.8"
],
"Labels": {
"author": "spring-boot"

@ -1,12 +1,37 @@
{
"User" : "root",
"Image" : "pack.local/ephemeral-builder",
"Cmd" : [ "/cnb/lifecycle/creator", "-app", "/workspace", "-platform", "/platform", "-run-image", "docker.io/cloudfoundry/run:latest", "-layers", "/layers", "-cache-dir", "/cache", "-launch-cache", "/launch-cache", "-daemon", "-skip-restore", "-process-type=web", "docker.io/library/my-application:latest" ],
"Env" : [ "CNB_PLATFORM_API=0.4" ],
"Labels" : {
"author" : "spring-boot"
"User": "root",
"Image": "pack.local/ephemeral-builder",
"Cmd": [
"/cnb/lifecycle/creator",
"-app",
"/workspace",
"-platform",
"/platform",
"-run-image",
"docker.io/cloudfoundry/run:latest",
"-layers",
"/layers",
"-cache-dir",
"/cache",
"-launch-cache",
"/launch-cache",
"-daemon",
"-skip-restore",
"docker.io/library/my-application:latest"
],
"Env": [
"CNB_PLATFORM_API=0.8"
],
"Labels": {
"author": "spring-boot"
},
"HostConfig" : {
"Binds" : [ "/var/run/docker.sock:/var/run/docker.sock", "pack-layers-aaaaaaaaaa:/layers", "pack-app-aaaaaaaaaa:/workspace", "pack-cache-b35197ac41ea.build:/cache", "pack-cache-b35197ac41ea.launch:/launch-cache" ]
"HostConfig": {
"Binds": [
"/var/run/docker.sock:/var/run/docker.sock",
"pack-layers-aaaaaaaaaa:/layers",
"pack-app-aaaaaaaaaa:/workspace",
"pack-cache-b35197ac41ea.build:/cache",
"pack-cache-b35197ac41ea.launch:/launch-cache"
]
}
}

@ -1,13 +1,37 @@
{
"User" : "root",
"Image" : "pack.local/ephemeral-builder",
"Cmd" : [ "/cnb/lifecycle/creator", "-app", "/workspace", "-platform", "/platform", "-run-image", "docker.io/cloudfoundry/run:latest", "-layers", "/layers", "-cache-dir", "/cache", "-launch-cache", "/launch-cache", "-daemon", "-process-type=web", "docker.io/library/my-application:latest" ],
"Env" : [ "CNB_PLATFORM_API=0.4" ],
"Labels" : {
"author" : "spring-boot"
"User": "root",
"Image": "pack.local/ephemeral-builder",
"Cmd": [
"/cnb/lifecycle/creator",
"-app",
"/workspace",
"-platform",
"/platform",
"-run-image",
"docker.io/cloudfoundry/run:latest",
"-layers",
"/layers",
"-cache-dir",
"/cache",
"-launch-cache",
"/launch-cache",
"-daemon",
"docker.io/library/my-application:latest"
],
"Env": [
"CNB_PLATFORM_API=0.8"
],
"Labels": {
"author": "spring-boot"
},
"HostConfig" : {
"NetworkMode" : "test",
"Binds" : [ "/var/run/docker.sock:/var/run/docker.sock", "pack-layers-aaaaaaaaaa:/layers", "pack-app-aaaaaaaaaa:/workspace", "pack-cache-b35197ac41ea.build:/cache", "pack-cache-b35197ac41ea.launch:/launch-cache" ]
"HostConfig": {
"NetworkMode": "test",
"Binds": [
"/var/run/docker.sock:/var/run/docker.sock",
"pack-layers-aaaaaaaaaa:/layers",
"pack-app-aaaaaaaaaa:/workspace",
"pack-cache-b35197ac41ea.build:/cache",
"pack-cache-b35197ac41ea.launch:/launch-cache"
]
}
}

@ -1,12 +1,36 @@
{
"User" : "root",
"Image" : "pack.local/ephemeral-builder",
"Cmd" : [ "/cnb/lifecycle/creator", "-app", "/workspace", "-platform", "/platform", "-run-image", "docker.io/cloudfoundry/run:latest", "-layers", "/layers", "-cache-dir", "/cache", "-launch-cache", "/launch-cache", "-daemon", "-process-type=web", "docker.io/library/my-application:latest" ],
"Env" : [ "CNB_PLATFORM_API=0.4" ],
"Labels" : {
"author" : "spring-boot"
"User": "root",
"Image": "pack.local/ephemeral-builder",
"Cmd": [
"/cnb/lifecycle/creator",
"-app",
"/workspace",
"-platform",
"/platform",
"-run-image",
"docker.io/cloudfoundry/run:latest",
"-layers",
"/layers",
"-cache-dir",
"/cache",
"-launch-cache",
"/launch-cache",
"-daemon",
"docker.io/library/my-application:latest"
],
"Env": [
"CNB_PLATFORM_API=0.8"
],
"Labels": {
"author": "spring-boot"
},
"HostConfig" : {
"Binds" : [ "/var/run/docker.sock:/var/run/docker.sock", "pack-layers-aaaaaaaaaa:/layers", "pack-app-aaaaaaaaaa:/workspace", "pack-cache-b35197ac41ea.build:/cache", "pack-cache-b35197ac41ea.launch:/launch-cache" ]
"HostConfig": {
"Binds": [
"/var/run/docker.sock:/var/run/docker.sock",
"pack-layers-aaaaaaaaaa:/layers",
"pack-app-aaaaaaaaaa:/workspace",
"pack-cache-b35197ac41ea.build:/cache",
"pack-cache-b35197ac41ea.launch:/launch-cache"
]
}
}
Loading…
Cancel
Save