Upgrades should not update environment (#276)

[Fixes #275]
This commit is contained in:
Alberto Ríos
2019-09-25 11:28:56 +02:00
committed by GitHub
parent ebe96f886d
commit 86d67441b8
3 changed files with 7 additions and 13 deletions

View File

@@ -191,8 +191,6 @@ public class CloudFoundryAppDeployer implements AppDeployer, ResourceLoaderAware
@Override
public Mono<UpdateApplicationResponse> update(UpdateApplicationRequest request) {
final String name = request.getName();
final Map<String, Object> environmentVariables =
getApplicationEnvironment(request.getProperties(), request.getEnvironment(), request.getServiceInstanceId());
return operationsUtils.getOperations(request.getProperties())
.flatMap(cfOperations -> cfOperations.applications()
@@ -201,9 +199,6 @@ public class CloudFoundryAppDeployer implements AppDeployer, ResourceLoaderAware
.doOnSuccess(response -> logger.info("Success getting application {}", name))
.doOnError(e -> logger.warn(String.format("Error getting application %s: %s", name, e.getMessage())))
.map(ApplicationDetail::getId)
.flatMap(applicationId ->
updateApplicationEnvironment(applicationId, environmentVariables, request.getProperties()).thenReturn(applicationId)
)
.flatMap(applicationId -> associateHostName(applicationId, request.getProperties()))
.flatMap(applicationId -> Mono.zip(Mono.just(applicationId),
upgradeApplication(request, applicationId)))
@@ -398,7 +393,11 @@ public class CloudFoundryAppDeployer implements AppDeployer, ResourceLoaderAware
.flatMap(packageId -> waitForPackageReady(packageId)
.map(Package::getId));
}
return getPackageForApplication(applicationId);
final Map<String, Object> environmentVariables =
getApplicationEnvironment(request.getProperties(), request.getEnvironment(), request.getServiceInstanceId());
return updateApplicationEnvironment(applicationId, environmentVariables, request.getProperties())
.flatMap(a -> getPackageForApplication(applicationId));
}
private Mono<String> getPackageForApplication(String applicationId) {

View File

@@ -289,12 +289,6 @@ class CloudFoundryAppDeployerUpdateApplicationTest {
@Test
void updateAppWithUpgrade() {
ArgumentCaptor<org.cloudfoundry.client.v2.applications.UpdateApplicationRequest> updateApplicationRequestCaptor =
ArgumentCaptor.forClass(org.cloudfoundry.client.v2.applications.UpdateApplicationRequest.class);
when(applicationsV2.update(updateApplicationRequestCaptor.capture()))
.thenReturn(Mono.just(UpdateApplicationResponse.builder().build()));
Map<String, String> properties = new HashMap<>();
properties.put("upgrade", "true");
@@ -309,6 +303,8 @@ class CloudFoundryAppDeployerUpdateApplicationTest {
StepVerifier.create(appDeployer.update(request))
.assertNext(response -> assertThat(response.getName()).isEqualTo(APP_NAME))
.verifyComplete();
verifyZeroInteractions(applicationsV2);
}
@Test