Skip to content

Commit 82cc7ab

Browse files
committed
Update Supported Deployment Information
This commit adds support for additional deployment status values and reasons, while retaining older options for backwards compatibility. It also adds filtering for the value and reason. [resolves #1039] Signed-off-by: Paul Harris <[email protected]>
1 parent 06e158f commit 82cc7ab

File tree

5 files changed

+61
-5
lines changed

5 files changed

+61
-5
lines changed

cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/deployments/Deployment.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,4 @@ public abstract class Deployment extends Resource {
9393
@Nullable
9494
public abstract Status getStatus();
9595

96-
9796
}

cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/deployments/DeploymentStatusReason.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import com.fasterxml.jackson.annotation.JsonValue;
2121

2222
/**
23-
* The state of a {@link Deployment}
23+
* The status reason of a {@link Deployment}
2424
*/
2525
public enum DeploymentStatusReason {
2626

@@ -29,6 +29,11 @@ public enum DeploymentStatusReason {
2929
*/
3030
CANCELED("CANCELED"),
3131

32+
/**
33+
* The canceling status reason
34+
*/
35+
CANCELING("CANCELING"),
36+
3237
/**
3338
* The degenerate status reason
3439
*/
@@ -39,6 +44,11 @@ public enum DeploymentStatusReason {
3944
*/
4045
DEPLOYED("DEPLOYED"),
4146

47+
/**
48+
* The deploying status reason
49+
*/
50+
DEPLOYING("DEPLOYING"),
51+
4252
/**
4353
* The superseded status reason
4454
*/
@@ -55,10 +65,14 @@ public static DeploymentStatusReason from(String s) {
5565
switch (s.toLowerCase()) {
5666
case "canceled":
5767
return CANCELED;
68+
case "canceling":
69+
return CANCELING;
5870
case "degenerate":
5971
return DEGENERATE;
6072
case "deployed":
6173
return DEPLOYED;
74+
case "deploying":
75+
return DEPLOYING;
6276
case "superseded":
6377
return SUPERSEDED;
6478
default:

cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/deployments/DeploymentStatusValue.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,25 @@
2020
import com.fasterxml.jackson.annotation.JsonValue;
2121

2222
/**
23-
* The state of a {@link Deployment}
23+
* The status value of a {@link Deployment}
2424
*/
2525
public enum DeploymentStatusValue {
2626

2727
/**
28-
* The deploying status value
28+
* The active status value
2929
*/
30-
DEPLOYING("DEPLOYING"),
30+
ACTIVE("ACTIVE"),
3131

3232
/**
3333
* The canceling status value
3434
*/
3535
CANCELING("CANCELING"),
3636

37+
/**
38+
* The deploying status value
39+
*/
40+
DEPLOYING("DEPLOYING"),
41+
3742
/**
3843
* The finalized status value
3944
*/
@@ -48,6 +53,8 @@ public enum DeploymentStatusValue {
4853
@JsonCreator
4954
public static DeploymentStatusValue from(String s) {
5055
switch (s.toLowerCase()) {
56+
case "active":
57+
return ACTIVE;
5158
case "deploying":
5259
return DEPLOYING;
5360
case "canceling":

cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/deployments/_ListDeploymentsRequest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,16 @@ abstract class _ListDeploymentsRequest extends PaginatedRequest {
4141
@FilterParameter("states")
4242
abstract List<DeploymentState> getStates();
4343

44+
/**
45+
* List of status reasons to filter by
46+
*/
47+
@FilterParameter("status_reasons")
48+
abstract List<DeploymentStatusReason> getStatusReasons();
49+
50+
/**
51+
* List of status values to filter by
52+
*/
53+
@FilterParameter("status_values")
54+
abstract List<DeploymentStatusValue> getStatusValues();
55+
4456
}

integration-test/src/test/java/org/cloudfoundry/client/v3/DeploymentsTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.cloudfoundry.client.v3.deployments.DeploymentRelationships;
2929
import org.cloudfoundry.client.v3.deployments.DeploymentResource;
3030
import org.cloudfoundry.client.v3.deployments.DeploymentState;
31+
import org.cloudfoundry.client.v3.deployments.DeploymentStatusValue;
3132
import org.cloudfoundry.client.v3.deployments.GetDeploymentRequest;
3233
import org.cloudfoundry.client.v3.deployments.ListDeploymentsRequest;
3334
import org.cloudfoundry.operations.CloudFoundryOperations;
@@ -207,6 +208,29 @@ public void listFilterByState() throws Exception {
207208
.verify(Duration.ofMinutes(5));
208209
}
209210

211+
@Test
212+
public void listFilterByStatusValues() throws Exception {
213+
String name = this.nameFactory.getApplicationName();
214+
Path path = new ClassPathResource("test-application.zip").getFile().toPath();
215+
216+
createApplicationId(this.cloudFoundryOperations, name, path)
217+
.flatMap(applicationId -> Mono.zip(
218+
Mono.just(applicationId),
219+
getDropletId(this.cloudFoundryClient, applicationId)
220+
))
221+
.flatMap(function((applicationId, dropletId) -> createDeploymentId(this.cloudFoundryClient, applicationId, dropletId)))
222+
.flatMapMany(deploymentId -> PaginationUtils.requestClientV3Resources(page -> this.cloudFoundryClient.deploymentsV3()
223+
.list(ListDeploymentsRequest.builder()
224+
.statusValue(DeploymentStatusValue.DEPLOYING)
225+
.page(page)
226+
.build()))
227+
.filter(resource -> deploymentId.equals(resource.getId())))
228+
.as(StepVerifier::create)
229+
.expectNextCount(1)
230+
.expectComplete()
231+
.verify(Duration.ofMinutes(5));
232+
}
233+
210234
private static Mono<String> createApplicationId(CloudFoundryOperations cloudFoundryOperations, String name, Path path) {
211235
return requestCreateApplication(cloudFoundryOperations, name, path)
212236
.then(getApplicationId(cloudFoundryOperations, name));

0 commit comments

Comments
 (0)