Adding stack support (#856)

This commit is contained in:
Alberto C. Ríos
2023-09-18 15:13:40 +02:00
committed by GitHub
parent 6f400d5f51
commit 2eadb3d2d6
10 changed files with 80 additions and 2 deletions

View File

@@ -706,6 +706,7 @@ public class CloudFoundryAppDeployer implements AppDeployer, ResourceLoaderAware
.services(request.getServices())
.instances(instances(deploymentProperties))
.memory(memory(deploymentProperties))
.stack(stack(deploymentProperties))
.disk(diskQuota(deploymentProperties))
.healthCheckType(healthCheck(deploymentProperties))
.healthCheckHttpEndpoint(healthCheckEndpoint(deploymentProperties))
@@ -1047,6 +1048,11 @@ public class CloudFoundryAppDeployer implements AppDeployer, ResourceLoaderAware
.orElse(this.defaultDeploymentProperties.getBuildpacks());
}
private String stack(Map<String, String> properties) {
return Optional.ofNullable(properties.get(CloudFoundryDeploymentProperties.STACK_PROPERTY_KEY))
.orElse(this.defaultDeploymentProperties.getStack());
}
private String javaOpts(Map<String, String> properties) {
return Optional.ofNullable(properties.get(CloudFoundryDeploymentProperties.JAVA_OPTS_PROPERTY_KEY))
.orElse(this.defaultDeploymentProperties.getJavaOpts());

View File

@@ -90,6 +90,11 @@ public class CloudFoundryDeploymentProperties extends DeploymentProperties {
*/
protected static final String BUILDPACKS_PROPERTY_KEY = "buildpacks";
/**
* Key for storing the stack deployment property
*/
protected static final String STACK_PROPERTY_KEY = "stack";
/**
* Key for storing JAVA_OPTS deployment property
*/
@@ -126,6 +131,11 @@ public class CloudFoundryDeploymentProperties extends DeploymentProperties {
*/
private String buildpacks = "";
/**
* The stack to use for deploying the application.
*/
private String stack;
/**
* The type of health check to perform on deployed application, if not overridden per-app. Defaults to PORT
*/
@@ -194,6 +204,14 @@ public class CloudFoundryDeploymentProperties extends DeploymentProperties {
this.buildpacks = buildpacks;
}
public String getStack() {
return stack;
}
public void setStack(String stack) {
this.stack = stack;
}
public boolean isEnableRandomAppNamePrefix() {
return enableRandomAppNamePrefix;
}

View File

@@ -208,6 +208,7 @@ class CloudFoundryAppDeployerTest {
.property(CloudFoundryDeploymentProperties.HEALTHCHECK_PROPERTY_KEY, "http")
.property(CloudFoundryDeploymentProperties.HEALTHCHECK_HTTP_ENDPOINT_PROPERTY_KEY, "/healthcheck")
.property(CloudFoundryDeploymentProperties.BUILDPACKS_PROPERTY_KEY, "buildpack1,buildpack2")
.property(CloudFoundryDeploymentProperties.STACK_PROPERTY_KEY, "customstack")
.property(CloudFoundryDeploymentProperties.DOMAINS_PROPERTY, "domain1,domain2")
.property(DeploymentProperties.HOST_PROPERTY_KEY, "host")
.property(CloudFoundryDeploymentProperties.NO_ROUTE_PROPERTY, "true")
@@ -226,6 +227,7 @@ class CloudFoundryAppDeployerTest {
.healthCheckType(ApplicationHealthCheck.HTTP)
.healthCheckHttpEndpoint("/healthcheck")
.buildpacks("buildpack1", "buildpack2")
.stack("customstack")
.domains("domain2", "domain1") // domains is a list so order matters
.host("host")
.noRoute(true)
@@ -295,6 +297,7 @@ class CloudFoundryAppDeployerTest {
.property(CloudFoundryDeploymentProperties.DOMAINS_PROPERTY, "domain2")
.property(DeploymentProperties.HOST_PROPERTY_KEY, "host2")
.property(CloudFoundryDeploymentProperties.NO_ROUTE_PROPERTY, "true")
.property(CloudFoundryDeploymentProperties.STACK_PROPERTY_KEY, "customstack")
.build();
StepVerifier.create(appDeployer.deploy(request))
@@ -312,6 +315,7 @@ class CloudFoundryAppDeployerTest {
.buildpack("buildpack2")
.domains("domain2", "domain1")
.host("host2")
.stack("customstack")
.noRoute(true)
.build();