Skip to content

Commit 0b299d2

Browse files
committed
Merge branch '3.x'
2 parents 0049f61 + 097eb72 commit 0b299d2

File tree

5 files changed

+47
-0
lines changed

5 files changed

+47
-0
lines changed

cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/services/AbstractServiceInstanceSummary.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.cloudfoundry.operations.services;
1818

1919
import org.cloudfoundry.Nullable;
20+
import org.cloudfoundry.client.v2.MaintenanceInfo;
2021

2122
import java.util.List;
2223

@@ -41,6 +42,12 @@ public abstract class AbstractServiceInstanceSummary {
4142
@Nullable
4243
abstract String getLastOperation();
4344

45+
/**
46+
* The maintenance info
47+
*/
48+
@Nullable
49+
abstract MaintenanceInfo getMaintenanceInfo();
50+
4451
/**
4552
* The service instance name
4653
*/

cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/services/DefaultServices.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,7 @@ private static Mono<UpdateServiceInstanceResponse> requestUpdateServiceInstance(
927927
.update(org.cloudfoundry.client.v2.serviceinstances
928928
.UpdateServiceInstanceRequest.builder()
929929
.acceptsIncomplete(true)
930+
.maintenanceInfo(request.getMaintenanceInfo())
930931
.parameters(request.getParameters())
931932
.serviceInstanceId(serviceInstanceId)
932933
.servicePlanId(servicePlanId)
@@ -958,6 +959,7 @@ private static ServiceInstance toServiceInstance(UnionServiceInstanceResource re
958959
.documentationUrl(documentationUrl.orElse(null))
959960
.id(ResourceUtils.getId(resource))
960961
.lastOperation(lastOperation.getType())
962+
.maintenanceInfo(serviceInstanceEntity.getMaintenanceInfo())
961963
.message(lastOperation.getDescription())
962964
.name(serviceInstanceEntity.getName())
963965
.plan(plan.orElse(null))
@@ -989,6 +991,7 @@ private static Flux<ServiceInstanceSummary> toServiceInstanceSummary(GetSpaceSum
989991
.applications(Optional.ofNullable(applicationBindings.get(service.getName())).orElse(Collections.emptyList()))
990992
.id(service.getId())
991993
.lastOperation(service.getLastOperation() == null ? null : service.getLastOperation().getDescription())
994+
.maintenanceInfo(service.getMaintenanceInfo())
992995
.name(service.getName())
993996
.plan(service.getServicePlan() == null ? null : service.getServicePlan().getName())
994997
.service(service.getServicePlan() == null ? null : service.getServicePlan().getService().getLabel())

cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/services/_UpdateServiceInstanceRequest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import org.cloudfoundry.AllowNulls;
2020
import org.cloudfoundry.Nullable;
21+
import org.cloudfoundry.client.v2.MaintenanceInfo;
2122
import org.immutables.value.Value;
2223

2324
import java.time.Duration;
@@ -38,6 +39,12 @@ Duration getCompletionTimeout() {
3839
return Duration.ofMinutes(5);
3940
}
4041

42+
/**
43+
* The maintenance info to upgrade to
44+
*/
45+
@Nullable
46+
abstract MaintenanceInfo getMaintenanceInfo();
47+
4148
/**
4249
* The parameters of the service instance
4350
*/

cloudfoundry-operations/src/test/java/org/cloudfoundry/operations/services/DefaultServicesTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import org.cloudfoundry.client.CloudFoundryClient;
2020
import org.cloudfoundry.client.v2.ClientV2Exception;
21+
import org.cloudfoundry.client.v2.MaintenanceInfo;
2122
import org.cloudfoundry.client.v2.Metadata;
2223
import org.cloudfoundry.client.v2.applications.ApplicationEntity;
2324
import org.cloudfoundry.client.v2.applications.ApplicationResource;
@@ -480,6 +481,10 @@ public void getServiceInstanceManaged() {
480481
.documentationUrl("test-documentation-url")
481482
.id("test-service-instance-id")
482483
.lastOperation("test-type")
484+
.maintenanceInfo(MaintenanceInfo.builder()
485+
.description("test-description")
486+
.version("test-version")
487+
.build())
483488
.name("test-service-instance-name")
484489
.plan("test-service-plan")
485490
.tag("test-tag")

integration-test/src/test/java/org/cloudfoundry/client/v2/ServiceInstancesTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package org.cloudfoundry.client.v2;
1818

1919
import org.cloudfoundry.AbstractIntegrationTest;
20+
import org.cloudfoundry.CloudFoundryVersion;
21+
import org.cloudfoundry.IfCloudFoundryVersion;
2022
import org.cloudfoundry.client.CloudFoundryClient;
2123
import org.cloudfoundry.client.v2.applications.CreateApplicationRequest;
2224
import org.cloudfoundry.client.v2.applications.CreateApplicationResponse;
@@ -778,6 +780,29 @@ public void updateEmptyCollections() {
778780
.verify(Duration.ofMinutes(5));
779781
}
780782

783+
@IfCloudFoundryVersion(greaterThanOrEqualTo = CloudFoundryVersion.PCF_2_7)
784+
@Test
785+
public void upgrade() {
786+
String serviceInstanceName = this.nameFactory.getServiceInstanceName();
787+
788+
this.spaceId
789+
.flatMap(spaceId -> createServiceInstanceId(this.cloudFoundryClient, this.serviceBrokerId, serviceInstanceName, this.serviceName, spaceId))
790+
.flatMap(serviceInstanceId -> this.cloudFoundryClient.serviceInstances()
791+
.update(UpdateServiceInstanceRequest.builder()
792+
.maintenanceInfo(MaintenanceInfo.builder()
793+
.description("test-update")
794+
.version("9.9")
795+
.build())
796+
.serviceInstanceId(serviceInstanceId)
797+
.build()))
798+
.thenMany(requestListServiceInstances(this.cloudFoundryClient, serviceInstanceName))
799+
.map(resource -> ResourceUtils.getEntity(resource).getMaintenanceInfo().getVersion())
800+
.as(StepVerifier::create)
801+
.consumeErrorWith(t -> assertThat(t).isInstanceOf(ClientV2Exception.class).hasMessageMatching("CF-MaintenanceInfoNotSupported\\([0-9]+\\): The service broker does not support upgrades " +
802+
"for service instances created from this plan."))
803+
.verify(Duration.ofMinutes(5));
804+
}
805+
781806
private static Mono<BindServiceInstanceRouteResponse> createAndBindRoute(CloudFoundryClient cloudFoundryClient, String domainName, String organizationId, String spaceId, String
782807
serviceInstanceId) {
783808
return createPrivateDomainId(cloudFoundryClient, domainName, organizationId)

0 commit comments

Comments
 (0)