Apply spring formatter and checkstyle rules
This commit is contained in:
13
build.gradle
13
build.gradle
@@ -1,7 +1,7 @@
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -28,7 +28,9 @@ buildscript {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "io.spring.nohttp"
|
||||
id 'checkstyle'
|
||||
id 'io.spring.nohttp'
|
||||
id 'io.spring.javaformat'
|
||||
id 'distribution'
|
||||
id 'jacoco'
|
||||
}
|
||||
@@ -193,7 +195,8 @@ configure(libraryProjects) {
|
||||
}
|
||||
|
||||
configure(staticAnalysisProjects) {
|
||||
apply plugin: "checkstyle"
|
||||
apply plugin: 'checkstyle'
|
||||
apply plugin: 'io.spring.javaformat'
|
||||
apply plugin: "jacoco"
|
||||
|
||||
checkstyle {
|
||||
@@ -205,6 +208,10 @@ configure(staticAnalysisProjects) {
|
||||
}
|
||||
checkstyleTest {
|
||||
source = "src/test/java"
|
||||
configFile = configDirectory.get().file("checkstyle-test.xml").asFile
|
||||
}
|
||||
dependencies {
|
||||
checkstyle("io.spring.javaformat:spring-javaformat-checkstyle:0.0.43")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
pluginManagement {
|
||||
plugins {
|
||||
id "io.spring.nohttp" version "0.0.11"
|
||||
id "io.spring.javaformat" version "0.0.43"
|
||||
id 'org.springframework.boot' version "3.4.2"
|
||||
id 'org.asciidoctor.jvm.pdf' version '4.0.4'
|
||||
id 'org.asciidoctor.jvm.convert' version '4.0.4'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020. the original author or authors.
|
||||
* Copyright 2016-2020. 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.
|
||||
|
||||
@@ -29,14 +29,15 @@ import org.springframework.cloud.servicebroker.service.ServiceInstanceBindingSer
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
/**
|
||||
* A Spring Boot application for running acceptance tests
|
||||
* A Spring Boot application for running acceptance tests.
|
||||
*
|
||||
* @author Roy Clarkson
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class AppBrokerApplication {
|
||||
|
||||
/**
|
||||
* main application entry point
|
||||
*
|
||||
* main application entry point.
|
||||
* @param args the args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
@@ -44,8 +45,7 @@ public class AppBrokerApplication {
|
||||
}
|
||||
|
||||
/**
|
||||
* A no-op CreateServiceInstanceWorkflow bean
|
||||
*
|
||||
* A no-op CreateServiceInstanceWorkflow bean.
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
@@ -54,8 +54,7 @@ public class AppBrokerApplication {
|
||||
}
|
||||
|
||||
/**
|
||||
* A no-op UpdateServiceInstanceWorkflow bean
|
||||
*
|
||||
* A no-op UpdateServiceInstanceWorkflow bean.
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
@@ -64,8 +63,7 @@ public class AppBrokerApplication {
|
||||
}
|
||||
|
||||
/**
|
||||
* A no-op DeleteServiceInstanceWorkflow bean
|
||||
*
|
||||
* A no-op DeleteServiceInstanceWorkflow bean.
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
@@ -74,8 +72,7 @@ public class AppBrokerApplication {
|
||||
}
|
||||
|
||||
/**
|
||||
* A no-op ServiceInstanceBindingService bean
|
||||
*
|
||||
* A no-op ServiceInstanceBindingService bean.
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors
|
||||
* Copyright 2002-2024 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -24,7 +24,9 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* A controller for testing the {@link BackingAppManagementService}
|
||||
* A controller for testing the {@link BackingAppManagementService}.
|
||||
*
|
||||
* @author Roy Clarkson
|
||||
*/
|
||||
@RestController
|
||||
public class ManagementController {
|
||||
@@ -32,8 +34,7 @@ public class ManagementController {
|
||||
private final BackingAppManagementService service;
|
||||
|
||||
/**
|
||||
* Construct a new {@literal ManagementController}
|
||||
*
|
||||
* Construct a new {@literal ManagementController}.
|
||||
* @param service the service to test
|
||||
*/
|
||||
public ManagementController(BackingAppManagementService service) {
|
||||
@@ -41,66 +42,56 @@ public class ManagementController {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests service start
|
||||
*
|
||||
* Tests service start.
|
||||
* @param serviceInstanceId the id of the service to test
|
||||
* @param serviceName the name of the service
|
||||
* @param planName the name of the plan
|
||||
* @return a response
|
||||
*/
|
||||
@GetMapping("/start/{serviceName}/{planName}/{serviceInstanceId}")
|
||||
public Mono<String> startApplications(
|
||||
@PathVariable String serviceInstanceId,
|
||||
@PathVariable String serviceName,
|
||||
@PathVariable String planName
|
||||
) {
|
||||
return service.start(serviceInstanceId, serviceName, planName)
|
||||
.thenReturn("starting " + serviceInstanceId);
|
||||
public Mono<String> startApplications(@PathVariable String serviceInstanceId, @PathVariable String serviceName,
|
||||
@PathVariable String planName) {
|
||||
return this.service.start(serviceInstanceId, serviceName, planName).thenReturn("starting " + serviceInstanceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests service stop
|
||||
*
|
||||
* Tests service stop.
|
||||
* @param serviceInstanceId the id of the service to test
|
||||
* @param serviceName the name of the service
|
||||
* @param planName the name of the plan
|
||||
* @return a response
|
||||
*/
|
||||
@GetMapping("/stop/{serviceName}/{planName}/{serviceInstanceId}")
|
||||
public Mono<String> stopApplications(
|
||||
@PathVariable String serviceInstanceId,
|
||||
@PathVariable String serviceName,
|
||||
@PathVariable String planName
|
||||
) {
|
||||
return service.stop(serviceInstanceId, serviceName, planName)
|
||||
.thenReturn("stopping " + serviceInstanceId);
|
||||
public Mono<String> stopApplications(@PathVariable String serviceInstanceId, @PathVariable String serviceName,
|
||||
@PathVariable String planName) {
|
||||
return this.service.stop(serviceInstanceId, serviceName, planName).thenReturn("stopping " + serviceInstanceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests service restart
|
||||
*
|
||||
* Tests service restart.
|
||||
* @param serviceInstanceId the id of the service to test
|
||||
* @param serviceName the name of the service
|
||||
* @param planName the name of the plan
|
||||
* @return a response
|
||||
*/
|
||||
@GetMapping("/restart/{serviceName}/{planName}/{serviceInstanceId}")
|
||||
public Mono<String> restartApplications(
|
||||
@PathVariable String serviceInstanceId,
|
||||
@PathVariable String serviceName,
|
||||
@PathVariable String planName
|
||||
) {
|
||||
return service.restart(serviceInstanceId, serviceName, planName)
|
||||
public Mono<String> restartApplications(@PathVariable String serviceInstanceId, @PathVariable String serviceName,
|
||||
@PathVariable String planName) {
|
||||
return this.service.restart(serviceInstanceId, serviceName, planName)
|
||||
.thenReturn("restarting " + serviceInstanceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests service restage
|
||||
*
|
||||
* Tests service restage.
|
||||
* @param serviceInstanceId the id of the service to test
|
||||
* @param serviceName the name of the service
|
||||
* @param planName the name of the plan
|
||||
* @return a response
|
||||
*/
|
||||
@GetMapping("/restage/{serviceName}/{planName}/{serviceInstanceId}")
|
||||
public Mono<String> restageApplications(
|
||||
@PathVariable String serviceInstanceId,
|
||||
@PathVariable String serviceName,
|
||||
@PathVariable String planName
|
||||
) {
|
||||
return service.restage(serviceInstanceId, serviceName, planName)
|
||||
public Mono<String> restageApplications(@PathVariable String serviceInstanceId, @PathVariable String serviceName,
|
||||
@PathVariable String planName) {
|
||||
return this.service.restage(serviceInstanceId, serviceName, planName)
|
||||
.thenReturn("restaging " + serviceInstanceId);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2016-2024 the original author or authors
|
||||
* Copyright 2016-2024 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.cloud.appbroker.acceptance.logging;
|
||||
|
||||
|
||||
import org.cloudfoundry.client.CloudFoundryClient;
|
||||
import org.cloudfoundry.client.v3.applications.ApplicationResource;
|
||||
import org.cloudfoundry.client.v3.applications.ListApplicationsRequest;
|
||||
@@ -35,23 +34,21 @@ class BackingApplicationIdsProvider implements ApplicationIdsProvider {
|
||||
|
||||
private final CloudFoundryOperations cloudFoundryOperations;
|
||||
|
||||
public BackingApplicationIdsProvider(CloudFoundryClient cloudFoundryClient,
|
||||
CloudFoundryOperations cloudFoundryOperations) {
|
||||
BackingApplicationIdsProvider(CloudFoundryClient cloudFoundryClient,
|
||||
CloudFoundryOperations cloudFoundryOperations) {
|
||||
this.cloudFoundryClient = cloudFoundryClient;
|
||||
this.cloudFoundryOperations = cloudFoundryOperations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<String> getApplicationIds(String serviceInstanceId) {
|
||||
return cloudFoundryOperations.spaces().get(GetSpaceRequest.builder().name(serviceInstanceId).build())
|
||||
return this.cloudFoundryOperations.spaces()
|
||||
.get(GetSpaceRequest.builder().name(serviceInstanceId).build())
|
||||
.map(SpaceDetail::getId)
|
||||
.flatMap(spaceId ->
|
||||
cloudFoundryClient.applicationsV3()
|
||||
.list(ListApplicationsRequest.builder().spaceIds(spaceId).build())
|
||||
)
|
||||
.flatMapMany(
|
||||
listApplicationsResponse -> Flux.fromIterable(listApplicationsResponse.getResources())
|
||||
.map(ApplicationResource::getId));
|
||||
.flatMap((spaceId) -> this.cloudFoundryClient.applicationsV3()
|
||||
.list(ListApplicationsRequest.builder().spaceIds(spaceId).build()))
|
||||
.flatMapMany((listApplicationsResponse) -> Flux.fromIterable(listApplicationsResponse.getResources())
|
||||
.map(ApplicationResource::getId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2002-2024 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Acceptance test application logging.
|
||||
*/
|
||||
package org.springframework.cloud.appbroker.acceptance.logging;
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2002-2024 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Acceptance test application.
|
||||
*/
|
||||
package org.springframework.cloud.appbroker.acceptance;
|
||||
@@ -27,7 +27,10 @@ import org.springframework.cloud.servicebroker.model.instance.CreateServiceInsta
|
||||
import org.springframework.cloud.servicebroker.model.instance.CreateServiceInstanceResponse.CreateServiceInstanceResponseBuilder;
|
||||
|
||||
/**
|
||||
* A no-op implementation of {@link CreateServiceInstanceWorkflow}
|
||||
* A no-op implementation of {@link CreateServiceInstanceWorkflow}.
|
||||
*
|
||||
* @author Scott Frederick
|
||||
* @author Roy Clarkson
|
||||
*/
|
||||
public class NoOpCreateServiceInstanceWorkflow implements CreateServiceInstanceWorkflow {
|
||||
|
||||
@@ -46,12 +49,12 @@ public class NoOpCreateServiceInstanceWorkflow implements CreateServiceInstanceW
|
||||
if (LOG.isInfoEnabled()) {
|
||||
LOG.info("Got request to create service instance: " + request);
|
||||
}
|
||||
return Mono.just(request.getServiceDefinitionId().equals(backingServiceId));
|
||||
return Mono.just(request.getServiceDefinitionId().equals(this.backingServiceId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<CreateServiceInstanceResponseBuilder> buildResponse(CreateServiceInstanceRequest request,
|
||||
CreateServiceInstanceResponseBuilder responseBuilder) {
|
||||
CreateServiceInstanceResponseBuilder responseBuilder) {
|
||||
if (LOG.isInfoEnabled()) {
|
||||
LOG.info("Got request to create service instance: " + request);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,9 @@ import org.springframework.cloud.servicebroker.model.instance.DeleteServiceInsta
|
||||
import org.springframework.cloud.servicebroker.model.instance.DeleteServiceInstanceResponse.DeleteServiceInstanceResponseBuilder;
|
||||
|
||||
/**
|
||||
* A no-op implementation of {@link DeleteServiceInstanceWorkflow}
|
||||
* A no-op implementation of {@link DeleteServiceInstanceWorkflow}.
|
||||
*
|
||||
* @author Scott Frederick
|
||||
*/
|
||||
public class NoOpDeleteServiceInstanceWorkflow implements DeleteServiceInstanceWorkflow {
|
||||
|
||||
@@ -39,12 +41,12 @@ public class NoOpDeleteServiceInstanceWorkflow implements DeleteServiceInstanceW
|
||||
|
||||
@Override
|
||||
public Mono<Boolean> accept(DeleteServiceInstanceRequest request) {
|
||||
return Mono.just(request.getServiceDefinitionId().equals(backingServiceId));
|
||||
return Mono.just(request.getServiceDefinitionId().equals(this.backingServiceId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<DeleteServiceInstanceResponseBuilder> buildResponse(DeleteServiceInstanceRequest request,
|
||||
DeleteServiceInstanceResponseBuilder responseBuilder) {
|
||||
DeleteServiceInstanceResponseBuilder responseBuilder) {
|
||||
return Mono.just(responseBuilder);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,19 +26,22 @@ import org.springframework.cloud.servicebroker.model.binding.DeleteServiceInstan
|
||||
import org.springframework.cloud.servicebroker.service.ServiceInstanceBindingService;
|
||||
|
||||
/**
|
||||
* A no-op implementation of {@link ServiceInstanceBindingService}
|
||||
* A no-op implementation of {@link ServiceInstanceBindingService}.
|
||||
*
|
||||
* @author Scott Frederick
|
||||
* @author Roy Clarkson
|
||||
*/
|
||||
public class NoOpServiceInstanceBindingService implements ServiceInstanceBindingService {
|
||||
|
||||
@Override
|
||||
public Mono<CreateServiceInstanceBindingResponse> createServiceInstanceBinding(
|
||||
CreateServiceInstanceBindingRequest request) {
|
||||
CreateServiceInstanceBindingRequest request) {
|
||||
return Mono.just(CreateServiceInstanceAppBindingResponse.builder().build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<DeleteServiceInstanceBindingResponse> deleteServiceInstanceBinding(
|
||||
DeleteServiceInstanceBindingRequest request) {
|
||||
DeleteServiceInstanceBindingRequest request) {
|
||||
return Mono.just(DeleteServiceInstanceBindingResponse.builder().build());
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@ import org.springframework.cloud.servicebroker.model.instance.UpdateServiceInsta
|
||||
import org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceResponse.UpdateServiceInstanceResponseBuilder;
|
||||
|
||||
/**
|
||||
* A no-op implementation of {@link UpdateServiceInstanceWorkflow}
|
||||
* A no-op implementation of {@link UpdateServiceInstanceWorkflow}.
|
||||
*
|
||||
* @author Scott Frederick
|
||||
*/
|
||||
public class NoOpUpdateServiceInstanceWorkflow implements UpdateServiceInstanceWorkflow {
|
||||
|
||||
@@ -39,12 +41,12 @@ public class NoOpUpdateServiceInstanceWorkflow implements UpdateServiceInstanceW
|
||||
|
||||
@Override
|
||||
public Mono<Boolean> accept(UpdateServiceInstanceRequest request) {
|
||||
return Mono.just(request.getServiceDefinitionId().equals(backingServiceId));
|
||||
return Mono.just(request.getServiceDefinitionId().equals(this.backingServiceId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<UpdateServiceInstanceResponseBuilder> buildResponse(UpdateServiceInstanceRequest request,
|
||||
UpdateServiceInstanceResponseBuilder responseBuilder) {
|
||||
UpdateServiceInstanceResponseBuilder responseBuilder) {
|
||||
return Mono.just(responseBuilder);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2002-2024 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Acceptance test application services.
|
||||
*/
|
||||
package org.springframework.cloud.appbroker.acceptance.services;
|
||||
@@ -24,7 +24,7 @@ public class AcceptanceTestProperties {
|
||||
private String brokerAppPath;
|
||||
|
||||
public String getBrokerAppPath() {
|
||||
return brokerAppPath;
|
||||
return this.brokerAppPath;
|
||||
}
|
||||
|
||||
public void setBrokerAppPath(String brokerAppPath) {
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD})
|
||||
@Target({ ElementType.ANNOTATION_TYPE, ElementType.METHOD })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface AppBrokerTestProperties {
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors
|
||||
* Copyright 2002-2020 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -27,7 +27,7 @@ import reactor.test.StepVerifier;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class AppManagementRestageAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
class AppManagementRestageAcceptanceTests extends CloudFoundryAcceptanceTests {
|
||||
|
||||
private static final String SUFFIX = "app-management-restage";
|
||||
|
||||
@@ -58,35 +58,30 @@ class AppManagementRestageAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
StepVerifier.create(userCloudFoundryService.deleteServiceInstance(SI_NAME))
|
||||
.verifyComplete();
|
||||
StepVerifier.create(userCloudFoundryService.deleteServiceInstance(SI_NAME)).verifyComplete();
|
||||
|
||||
StepVerifier.create(userCloudFoundryService.createServiceInstance(PLAN_NAME, APP_SERVICE_NAME, SI_NAME, null))
|
||||
.verifyComplete();
|
||||
|
||||
StepVerifier.create(userCloudFoundryService.getServiceInstance(SI_NAME))
|
||||
.assertNext(serviceInstance -> assertThat(serviceInstance.getStatus()).isEqualTo("succeeded"))
|
||||
.assertNext((serviceInstance) -> assertThat(serviceInstance.getStatus()).isEqualTo("succeeded"))
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void cleanUp() {
|
||||
StepVerifier.create(userCloudFoundryService.deleteServiceInstance(SI_NAME))
|
||||
.verifyComplete();
|
||||
StepVerifier.create(userCloudFoundryService.deleteServiceInstance(SI_NAME)).verifyComplete();
|
||||
|
||||
StepVerifier.create(getApplications(APP_1, APP_2))
|
||||
.verifyError();
|
||||
StepVerifier.create(getApplications(APP_1, APP_2)).verifyError();
|
||||
}
|
||||
|
||||
@Test
|
||||
@AppBrokerTestProperties({
|
||||
"spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_1,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[1].name=" + APP_2,
|
||||
"spring.cloud.appbroker.services[0].apps[1].path=" + BACKING_APP_PATH
|
||||
})
|
||||
@AppBrokerTestProperties({ "spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_1,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[1].name=" + APP_2,
|
||||
"spring.cloud.appbroker.services[0].apps[1].path=" + BACKING_APP_PATH })
|
||||
void restageApps() throws Exception {
|
||||
List<ApplicationDetail> apps = getApplications(APP_1, APP_2).block();
|
||||
Date originallySince1 = apps.get(0).getInstanceDetails().get(0).getSince();
|
||||
@@ -94,7 +89,7 @@ class AppManagementRestageAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
assertThat(apps).extracting("runningInstances").containsOnly(1);
|
||||
|
||||
StepVerifier.create(manageApps(SI_NAME, APP_SERVICE_NAME, PLAN_NAME, "restage"))
|
||||
.assertNext(result -> assertThat(result).contains("restaging"))
|
||||
.assertNext((result) -> assertThat(result).contains("restaging"))
|
||||
.verifyComplete();
|
||||
|
||||
List<ApplicationDetail> restagedApps = getApplications(APP_1, APP_2).block();
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors
|
||||
* Copyright 2002-2020 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -27,7 +27,7 @@ import reactor.test.StepVerifier;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class AppManagementRestartAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
class AppManagementRestartAcceptanceTests extends CloudFoundryAcceptanceTests {
|
||||
|
||||
private static final String SUFFIX = "app-management-restart";
|
||||
|
||||
@@ -58,42 +58,37 @@ class AppManagementRestartAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
StepVerifier.create(userCloudFoundryService.deleteServiceInstance(SI_NAME))
|
||||
.verifyComplete();
|
||||
StepVerifier.create(userCloudFoundryService.deleteServiceInstance(SI_NAME)).verifyComplete();
|
||||
|
||||
StepVerifier.create(userCloudFoundryService.createServiceInstance(PLAN_NAME, APP_SERVICE_NAME, SI_NAME, null))
|
||||
.verifyComplete();
|
||||
|
||||
StepVerifier.create(userCloudFoundryService.getServiceInstance(SI_NAME))
|
||||
.assertNext(serviceInstance -> assertThat(serviceInstance.getStatus()).isEqualTo("succeeded"))
|
||||
.assertNext((serviceInstance) -> assertThat(serviceInstance.getStatus()).isEqualTo("succeeded"))
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void cleanUp() {
|
||||
StepVerifier.create(userCloudFoundryService.deleteServiceInstance(SI_NAME))
|
||||
.verifyComplete();
|
||||
StepVerifier.create(userCloudFoundryService.deleteServiceInstance(SI_NAME)).verifyComplete();
|
||||
|
||||
StepVerifier.create(getApplications(APP_1, APP_2))
|
||||
.verifyError();
|
||||
StepVerifier.create(getApplications(APP_1, APP_2)).verifyError();
|
||||
}
|
||||
|
||||
@Test
|
||||
@AppBrokerTestProperties({
|
||||
"spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_1,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[1].name=" + APP_2,
|
||||
"spring.cloud.appbroker.services[0].apps[1].path=" + BACKING_APP_PATH
|
||||
})
|
||||
@AppBrokerTestProperties({ "spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_1,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[1].name=" + APP_2,
|
||||
"spring.cloud.appbroker.services[0].apps[1].path=" + BACKING_APP_PATH })
|
||||
void restartApps() {
|
||||
List<ApplicationDetail> apps = getApplications(APP_1, APP_2).block();
|
||||
Date originallySince1 = apps.get(0).getInstanceDetails().get(0).getSince();
|
||||
Date originallySince2 = apps.get(1).getInstanceDetails().get(0).getSince();
|
||||
|
||||
StepVerifier.create(manageApps(SI_NAME, APP_SERVICE_NAME, PLAN_NAME, "restart"))
|
||||
.assertNext(result -> assertThat(result).contains("restarting"))
|
||||
.assertNext((result) -> assertThat(result).contains("restarting"))
|
||||
.verifyComplete();
|
||||
|
||||
List<ApplicationDetail> restagedApps = getApplications(APP_1, APP_2).block();
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors
|
||||
* Copyright 2002-2020 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -23,7 +23,7 @@ import reactor.test.StepVerifier;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class AppManagementStartAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
class AppManagementStartAcceptanceTests extends CloudFoundryAcceptanceTests {
|
||||
|
||||
private static final String SUFFIX = "app-management-start";
|
||||
|
||||
@@ -54,50 +54,44 @@ class AppManagementStartAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
StepVerifier.create(userCloudFoundryService.deleteServiceInstance(SI_NAME))
|
||||
.verifyComplete();
|
||||
StepVerifier.create(userCloudFoundryService.deleteServiceInstance(SI_NAME)).verifyComplete();
|
||||
|
||||
StepVerifier.create(userCloudFoundryService.createServiceInstance(PLAN_NAME, APP_SERVICE_NAME, SI_NAME, null))
|
||||
.verifyComplete();
|
||||
|
||||
StepVerifier.create(userCloudFoundryService.getServiceInstance(SI_NAME))
|
||||
.assertNext(serviceInstance -> assertThat(serviceInstance.getStatus()).isEqualTo("succeeded"))
|
||||
.assertNext((serviceInstance) -> assertThat(serviceInstance.getStatus()).isEqualTo("succeeded"))
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void cleanUp() {
|
||||
StepVerifier.create(userCloudFoundryService.deleteServiceInstance(SI_NAME))
|
||||
.verifyComplete();
|
||||
StepVerifier.create(userCloudFoundryService.deleteServiceInstance(SI_NAME)).verifyComplete();
|
||||
|
||||
StepVerifier.create(getApplications(APP_1, APP_2))
|
||||
.verifyError();
|
||||
StepVerifier.create(getApplications(APP_1, APP_2)).verifyError();
|
||||
}
|
||||
|
||||
@Test
|
||||
@AppBrokerTestProperties({
|
||||
"spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_1,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[1].name=" + APP_2,
|
||||
"spring.cloud.appbroker.services[0].apps[1].path=" + BACKING_APP_PATH
|
||||
})
|
||||
@AppBrokerTestProperties({ "spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_1,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[1].name=" + APP_2,
|
||||
"spring.cloud.appbroker.services[0].apps[1].path=" + BACKING_APP_PATH })
|
||||
void startApps() {
|
||||
StepVerifier.create(cloudFoundryService.stopApplication(APP_1)
|
||||
.then(cloudFoundryService.stopApplication(APP_2)))
|
||||
StepVerifier.create(cloudFoundryService.stopApplication(APP_1).then(cloudFoundryService.stopApplication(APP_2)))
|
||||
.verifyComplete();
|
||||
|
||||
StepVerifier.create(getApplications(APP_1, APP_2))
|
||||
.assertNext(apps -> assertThat(apps).extracting("runningInstances").containsOnly(0))
|
||||
.assertNext((apps) -> assertThat(apps).extracting("runningInstances").containsOnly(0))
|
||||
.verifyComplete();
|
||||
|
||||
StepVerifier.create(manageApps(SI_NAME, APP_SERVICE_NAME, PLAN_NAME, "start"))
|
||||
.assertNext(result -> assertThat(result).contains("starting"))
|
||||
.assertNext((result) -> assertThat(result).contains("starting"))
|
||||
.verifyComplete();
|
||||
|
||||
StepVerifier.create(getApplications(APP_1, APP_2))
|
||||
.assertNext(apps -> assertThat(apps).extracting("runningInstances").containsOnly(1))
|
||||
.assertNext((apps) -> assertThat(apps).extracting("runningInstances").containsOnly(1))
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors
|
||||
* Copyright 2002-2020 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -23,7 +23,7 @@ import reactor.test.StepVerifier;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class AppManagementStopAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
class AppManagementStopAcceptanceTests extends CloudFoundryAcceptanceTests {
|
||||
|
||||
private static final String SUFFIX = "app-management-stop";
|
||||
|
||||
@@ -54,42 +54,37 @@ class AppManagementStopAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
StepVerifier.create(userCloudFoundryService.deleteServiceInstance(SI_NAME))
|
||||
.verifyComplete();
|
||||
StepVerifier.create(userCloudFoundryService.deleteServiceInstance(SI_NAME)).verifyComplete();
|
||||
|
||||
StepVerifier.create(userCloudFoundryService.createServiceInstance(PLAN_NAME, APP_SERVICE_NAME, SI_NAME, null))
|
||||
.verifyComplete();
|
||||
|
||||
StepVerifier.create(userCloudFoundryService.getServiceInstance(SI_NAME))
|
||||
.assertNext(serviceInstance -> assertThat(serviceInstance.getStatus()).isEqualTo("succeeded"))
|
||||
.assertNext((serviceInstance) -> assertThat(serviceInstance.getStatus()).isEqualTo("succeeded"))
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void cleanUp() {
|
||||
StepVerifier.create(userCloudFoundryService.deleteServiceInstance(SI_NAME))
|
||||
.verifyComplete();
|
||||
StepVerifier.create(userCloudFoundryService.deleteServiceInstance(SI_NAME)).verifyComplete();
|
||||
|
||||
StepVerifier.create(getApplications(APP_1, APP_2))
|
||||
.verifyError();
|
||||
StepVerifier.create(getApplications(APP_1, APP_2)).verifyError();
|
||||
}
|
||||
|
||||
@Test
|
||||
@AppBrokerTestProperties({
|
||||
"spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_1,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[1].name=" + APP_2,
|
||||
"spring.cloud.appbroker.services[0].apps[1].path=" + BACKING_APP_PATH
|
||||
})
|
||||
@AppBrokerTestProperties({ "spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_1,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[1].name=" + APP_2,
|
||||
"spring.cloud.appbroker.services[0].apps[1].path=" + BACKING_APP_PATH })
|
||||
void stopApps() {
|
||||
StepVerifier.create(manageApps(SI_NAME, APP_SERVICE_NAME, PLAN_NAME, "stop"))
|
||||
.assertNext(result -> assertThat(result).contains("stopping"))
|
||||
.assertNext((result) -> assertThat(result).contains("stopping"))
|
||||
.verifyComplete();
|
||||
|
||||
StepVerifier.create(getApplications(APP_1, APP_2))
|
||||
.assertNext(apps -> assertThat(apps).extracting("runningInstances").containsOnly(0))
|
||||
.assertNext((apps) -> assertThat(apps).extracting("runningInstances").containsOnly(0))
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@@ -26,18 +26,18 @@ class BrokerProperties {
|
||||
|
||||
private final List<String> properties = new ArrayList<>();
|
||||
|
||||
public BrokerProperties(List<String> properties) {
|
||||
BrokerProperties(List<String> properties) {
|
||||
if (!CollectionUtils.isEmpty(properties)) {
|
||||
this.properties.addAll(properties);
|
||||
}
|
||||
}
|
||||
|
||||
public BrokerProperties(String... properties) {
|
||||
BrokerProperties(String... properties) {
|
||||
this(Arrays.asList(properties));
|
||||
}
|
||||
|
||||
public List<String> getProperties() {
|
||||
return properties;
|
||||
List<String> getProperties() {
|
||||
return this.properties;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,21 +28,20 @@ class BrokerPropertiesParameterResolver implements ParameterResolver {
|
||||
|
||||
@Override
|
||||
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
|
||||
throws ParameterResolutionException {
|
||||
throws ParameterResolutionException {
|
||||
return parameterContext.getParameter().getType() == BrokerProperties.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BrokerProperties resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
|
||||
throws ParameterResolutionException {
|
||||
throws ParameterResolutionException {
|
||||
String[] properties = getValueHolderProperties(extensionContext);
|
||||
return new BrokerProperties(properties);
|
||||
}
|
||||
|
||||
private static String[] getValueHolderProperties(ExtensionContext extensionContext) {
|
||||
Optional<Method> testInstance = extensionContext.getTestMethod();
|
||||
return testInstance
|
||||
.map(method -> method.getAnnotation(AppBrokerTestProperties.class).value())
|
||||
return testInstance.map((method) -> method.getAnnotation(AppBrokerTestProperties.class).value())
|
||||
.orElseGet(() -> new String[] {});
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,8 @@ import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import javax.net.ssl.SSLException;
|
||||
|
||||
import com.jayway.jsonpath.Configuration;
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
@@ -51,7 +53,6 @@ import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider;
|
||||
import com.jayway.jsonpath.spi.mapper.MappingProvider;
|
||||
import io.netty.handler.ssl.SslContextBuilder;
|
||||
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
|
||||
import javax.net.ssl.SSLException;
|
||||
import org.cloudfoundry.operations.applications.ApplicationDetail;
|
||||
import org.cloudfoundry.operations.applications.ApplicationEnvironments;
|
||||
import org.cloudfoundry.operations.applications.ApplicationSummary;
|
||||
@@ -86,26 +87,15 @@ import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.cloud.appbroker.acceptance.fixtures.cf.CloudFoundryClientConfiguration.APP_BROKER_CLIENT_AUTHORITIES;
|
||||
import static org.springframework.cloud.appbroker.acceptance.fixtures.cf.CloudFoundryClientConfiguration.APP_BROKER_CLIENT_SECRET;
|
||||
import static org.springframework.cloud.appbroker.acceptance.fixtures.cf.CloudFoundryClientConfiguration.USER_CLIENT_AUTHORITIES;
|
||||
import static org.springframework.cloud.appbroker.acceptance.fixtures.cf.CloudFoundryClientConfiguration.USER_CLIENT_ID;
|
||||
import static org.springframework.cloud.appbroker.acceptance.fixtures.cf.CloudFoundryClientConfiguration.USER_CLIENT_SECRET;
|
||||
|
||||
@SpringBootTest(classes = {
|
||||
CloudFoundryClientConfiguration.class,
|
||||
CloudFoundryService.class,
|
||||
UserCloudFoundryService.class,
|
||||
UaaService.class,
|
||||
HealthListener.class,
|
||||
RestTemplate.class
|
||||
})
|
||||
@SpringBootTest(classes = { CloudFoundryClientConfiguration.class, CloudFoundryService.class,
|
||||
UserCloudFoundryService.class, UaaService.class, HealthListener.class, RestTemplate.class })
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ExtendWith(BrokerPropertiesParameterResolver.class)
|
||||
@EnableConfigurationProperties(AcceptanceTestProperties.class)
|
||||
abstract class CloudFoundryAcceptanceTest {
|
||||
abstract class CloudFoundryAcceptanceTests {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CloudFoundryAcceptanceTest.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CloudFoundryAcceptanceTests.class);
|
||||
|
||||
private static final String BACKING_SERVICE_PLAN_ID = UUID.randomUUID().toString();
|
||||
|
||||
@@ -170,28 +160,26 @@ abstract class CloudFoundryAcceptanceTest {
|
||||
}
|
||||
|
||||
private List<String> getAppBrokerProperties(BrokerProperties brokerProperties) {
|
||||
String[] openServiceBrokerProperties = {
|
||||
"spring.cloud.openservicebroker.catalog.services[0].id=" + SERVICE_ID,
|
||||
"spring.cloud.openservicebroker.catalog.services[0].name=" + appServiceName(),
|
||||
"spring.cloud.openservicebroker.catalog.services[0].description=A service that deploys a backing app",
|
||||
"spring.cloud.openservicebroker.catalog.services[0].bindable=true",
|
||||
"spring.cloud.openservicebroker.catalog.services[0].metadata.properties.serviceInstanceLogsEndpoint=" +
|
||||
getServiceInstanceLogsEndpoint(),
|
||||
"spring.cloud.openservicebroker.catalog.services[0].plans[0].id=" + PLAN_ID,
|
||||
"spring.cloud.openservicebroker.catalog.services[0].plans[0].name=standard",
|
||||
"spring.cloud.openservicebroker.catalog.services[0].plans[0].bindable=true",
|
||||
"spring.cloud.openservicebroker.catalog.services[0].plans[0].description=A simple plan",
|
||||
"spring.cloud.openservicebroker.catalog.services[0].plans[0].free=true",
|
||||
"spring.cloud.openservicebroker.catalog.services[1].id=" + BACKING_SERVICE_ID,
|
||||
"spring.cloud.openservicebroker.catalog.services[1].name=" + backingServiceName(),
|
||||
"spring.cloud.openservicebroker.catalog.services[1].description=A backing service that can be bound to backing apps",
|
||||
"spring.cloud.openservicebroker.catalog.services[1].bindable=true",
|
||||
"spring.cloud.openservicebroker.catalog.services[1].plans[0].id=" + BACKING_SERVICE_PLAN_ID,
|
||||
"spring.cloud.openservicebroker.catalog.services[1].plans[0].name=standard",
|
||||
"spring.cloud.openservicebroker.catalog.services[1].plans[0].bindable=true",
|
||||
"spring.cloud.openservicebroker.catalog.services[1].plans[0].description=A simple plan",
|
||||
"spring.cloud.openservicebroker.catalog.services[1].plans[0].free=true"
|
||||
};
|
||||
String[] openServiceBrokerProperties = { "spring.cloud.openservicebroker.catalog.services[0].id=" + SERVICE_ID,
|
||||
"spring.cloud.openservicebroker.catalog.services[0].name=" + appServiceName(),
|
||||
"spring.cloud.openservicebroker.catalog.services[0].description=A service that deploys a backing app",
|
||||
"spring.cloud.openservicebroker.catalog.services[0].bindable=true",
|
||||
"spring.cloud.openservicebroker.catalog.services[0].metadata.properties.serviceInstanceLogsEndpoint="
|
||||
+ getServiceInstanceLogsEndpoint(),
|
||||
"spring.cloud.openservicebroker.catalog.services[0].plans[0].id=" + PLAN_ID,
|
||||
"spring.cloud.openservicebroker.catalog.services[0].plans[0].name=standard",
|
||||
"spring.cloud.openservicebroker.catalog.services[0].plans[0].bindable=true",
|
||||
"spring.cloud.openservicebroker.catalog.services[0].plans[0].description=A simple plan",
|
||||
"spring.cloud.openservicebroker.catalog.services[0].plans[0].free=true",
|
||||
"spring.cloud.openservicebroker.catalog.services[1].id=" + BACKING_SERVICE_ID,
|
||||
"spring.cloud.openservicebroker.catalog.services[1].name=" + backingServiceName(),
|
||||
"spring.cloud.openservicebroker.catalog.services[1].description=A backing service that can be bound to backing apps",
|
||||
"spring.cloud.openservicebroker.catalog.services[1].bindable=true",
|
||||
"spring.cloud.openservicebroker.catalog.services[1].plans[0].id=" + BACKING_SERVICE_PLAN_ID,
|
||||
"spring.cloud.openservicebroker.catalog.services[1].plans[0].name=standard",
|
||||
"spring.cloud.openservicebroker.catalog.services[1].plans[0].bindable=true",
|
||||
"spring.cloud.openservicebroker.catalog.services[1].plans[0].description=A simple plan",
|
||||
"spring.cloud.openservicebroker.catalog.services[1].plans[0].free=true" };
|
||||
|
||||
List<String> appBrokerProperties = new ArrayList<>();
|
||||
appBrokerProperties.addAll(Arrays.asList(openServiceBrokerProperties));
|
||||
@@ -200,7 +188,8 @@ abstract class CloudFoundryAcceptanceTest {
|
||||
}
|
||||
|
||||
private String getServiceInstanceLogsEndpoint() {
|
||||
return "https://" + testBrokerAppName() + "." + cloudFoundryProperties.getApiHost().substring(4) + "/logs/";
|
||||
return "https://" + testBrokerAppName() + "." + this.cloudFoundryProperties.getApiHost().substring(4)
|
||||
+ "/logs/";
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@@ -212,12 +201,12 @@ abstract class CloudFoundryAcceptanceTest {
|
||||
|
||||
@Override
|
||||
public JsonProvider jsonProvider() {
|
||||
return jacksonJsonProvider;
|
||||
return this.jacksonJsonProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MappingProvider mappingProvider() {
|
||||
return jacksonMappingProvider;
|
||||
return this.jacksonMappingProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -228,57 +217,57 @@ abstract class CloudFoundryAcceptanceTest {
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void tearDown(TestInfo testInfo) {
|
||||
blockingSubscribe(cloudFoundryService.getOrCreateDefaultOrg()
|
||||
void tearDown(TestInfo testInfo) {
|
||||
blockingSubscribe(this.cloudFoundryService.getOrCreateDefaultOrg()
|
||||
.map(OrganizationSummary::getId)
|
||||
.flatMap(orgId -> cloudFoundryService.getOrCreateDefaultSpace()
|
||||
.flatMap((orgId) -> this.cloudFoundryService.getOrCreateDefaultSpace()
|
||||
.map(SpaceSummary::getId)
|
||||
.flatMap(spaceId -> cleanup(orgId, spaceId))));
|
||||
.flatMap((spaceId) -> cleanup(orgId, spaceId))));
|
||||
}
|
||||
|
||||
private Mono<Void> initializeUser() {
|
||||
return cloudFoundryService.getOrCreateOrganization(userCloudFoundryService.getOrgName())
|
||||
return this.cloudFoundryService.getOrCreateOrganization(this.userCloudFoundryService.getOrgName())
|
||||
.map(OrganizationSummary::getId)
|
||||
.flatMap(orgId -> cloudFoundryService
|
||||
.getOrCreateSpace(userCloudFoundryService.getOrgName(), userCloudFoundryService.getSpaceName())
|
||||
.flatMap((orgId) -> this.cloudFoundryService
|
||||
.getOrCreateSpace(this.userCloudFoundryService.getOrgName(),
|
||||
this.userCloudFoundryService.getSpaceName())
|
||||
.map(SpaceSummary::getId)
|
||||
.flatMap(spaceId -> uaaService.createClient(USER_CLIENT_ID, USER_CLIENT_SECRET, USER_CLIENT_AUTHORITIES)
|
||||
.then(cloudFoundryService
|
||||
.associateClientWithOrgAndSpace(USER_CLIENT_ID, orgId, spaceId))));
|
||||
.flatMap((spaceId) -> this.uaaService
|
||||
.createClient(CloudFoundryClientConfiguration.USER_CLIENT_ID,
|
||||
CloudFoundryClientConfiguration.USER_CLIENT_SECRET,
|
||||
CloudFoundryClientConfiguration.USER_CLIENT_AUTHORITIES)
|
||||
.then(this.cloudFoundryService.associateClientWithOrgAndSpace(
|
||||
CloudFoundryClientConfiguration.USER_CLIENT_ID, orgId, spaceId))));
|
||||
}
|
||||
|
||||
private Mono<Void> initializeBroker(List<String> appBrokerProperties) {
|
||||
return cloudFoundryService.getOrCreateDefaultOrg()
|
||||
return this.cloudFoundryService.getOrCreateDefaultOrg()
|
||||
.map(OrganizationSummary::getId)
|
||||
.flatMap(orgId -> cloudFoundryService
|
||||
.getOrCreateDefaultSpace()
|
||||
.flatMap((orgId) -> this.cloudFoundryService.getOrCreateDefaultSpace()
|
||||
.map(SpaceSummary::getId)
|
||||
.flatMap(spaceId -> cleanup(orgId, spaceId)
|
||||
.then(uaaService.createClient(
|
||||
brokerClientId(),
|
||||
APP_BROKER_CLIENT_SECRET,
|
||||
APP_BROKER_CLIENT_AUTHORITIES))
|
||||
.then(cloudFoundryService
|
||||
.associateAppBrokerClientWithOrgAndSpace(brokerClientId(), orgId, spaceId))
|
||||
.then(cloudFoundryService
|
||||
.pushBrokerApp(testBrokerAppName(), getTestBrokerAppPath(), brokerClientId(),
|
||||
appBrokerProperties))
|
||||
.then(cloudFoundryService.createServiceBroker(serviceBrokerName(), testBrokerAppName()))
|
||||
.then(cloudFoundryService.enableServiceBrokerAccess(appServiceName()))
|
||||
.then(cloudFoundryService.enableServiceBrokerAccess(backingServiceName()))));
|
||||
.flatMap((spaceId) -> cleanup(orgId, spaceId)
|
||||
.then(this.uaaService.createClient(brokerClientId(),
|
||||
CloudFoundryClientConfiguration.APP_BROKER_CLIENT_SECRET,
|
||||
CloudFoundryClientConfiguration.APP_BROKER_CLIENT_AUTHORITIES))
|
||||
.then(this.cloudFoundryService.associateAppBrokerClientWithOrgAndSpace(brokerClientId(), orgId,
|
||||
spaceId))
|
||||
.then(this.cloudFoundryService.pushBrokerApp(testBrokerAppName(), getTestBrokerAppPath(),
|
||||
brokerClientId(), appBrokerProperties))
|
||||
.then(this.cloudFoundryService.createServiceBroker(serviceBrokerName(), testBrokerAppName()))
|
||||
.then(this.cloudFoundryService.enableServiceBrokerAccess(appServiceName()))
|
||||
.then(this.cloudFoundryService.enableServiceBrokerAccess(backingServiceName()))));
|
||||
}
|
||||
|
||||
private Mono<Void> updateBroker(List<String> appBrokerProperties) {
|
||||
return cloudFoundryService
|
||||
.updateBrokerApp(testBrokerAppName(), brokerClientId(), appBrokerProperties)
|
||||
.then(cloudFoundryService.updateServiceBroker(serviceBrokerName(), testBrokerAppName()));
|
||||
return this.cloudFoundryService.updateBrokerApp(testBrokerAppName(), brokerClientId(), appBrokerProperties)
|
||||
.then(this.cloudFoundryService.updateServiceBroker(serviceBrokerName(), testBrokerAppName()));
|
||||
}
|
||||
|
||||
private Mono<Void> cleanup(String orgId, String spaceId) {
|
||||
return cloudFoundryService.deleteServiceBroker(serviceBrokerName())
|
||||
.then(cloudFoundryService.deleteApp(testBrokerAppName()))
|
||||
.then(cloudFoundryService.removeAppBrokerClientFromOrgAndSpace(brokerClientId(), orgId, spaceId))
|
||||
.onErrorResume(e -> Mono.empty());
|
||||
return this.cloudFoundryService.deleteServiceBroker(serviceBrokerName())
|
||||
.then(this.cloudFoundryService.deleteApp(testBrokerAppName()))
|
||||
.then(this.cloudFoundryService.removeAppBrokerClientFromOrgAndSpace(brokerClientId(), orgId, spaceId))
|
||||
.onErrorResume((e) -> Mono.empty());
|
||||
}
|
||||
|
||||
protected void createServiceInstance(String serviceInstanceName) {
|
||||
@@ -289,13 +278,11 @@ abstract class CloudFoundryAcceptanceTest {
|
||||
createServiceInstance(appServiceName(), PLAN_NAME, serviceInstanceName, parameters);
|
||||
}
|
||||
|
||||
protected void createServiceInstance(String serviceName,
|
||||
String planName,
|
||||
String serviceInstanceName,
|
||||
Map<String, Object> parameters) {
|
||||
userCloudFoundryService.createServiceInstance(planName, serviceName, serviceInstanceName, parameters)
|
||||
protected void createServiceInstance(String serviceName, String planName, String serviceInstanceName,
|
||||
Map<String, Object> parameters) {
|
||||
this.userCloudFoundryService.createServiceInstance(planName, serviceName, serviceInstanceName, parameters)
|
||||
.then(getServiceInstanceMono(serviceInstanceName))
|
||||
.flatMap(serviceInstance -> {
|
||||
.flatMap((serviceInstance) -> {
|
||||
assertThat(serviceInstance.getStatus())
|
||||
.withFailMessage("Create service instance failed:" + serviceInstance.getMessage())
|
||||
.isEqualTo("succeeded");
|
||||
@@ -304,13 +291,11 @@ abstract class CloudFoundryAcceptanceTest {
|
||||
.block();
|
||||
}
|
||||
|
||||
protected void createBackingServiceInstance(String serviceName,
|
||||
String planName,
|
||||
String serviceInstanceName,
|
||||
Map<String, Object> parameters) {
|
||||
cloudFoundryService.createBackingServiceInstance(planName, serviceName, serviceInstanceName, parameters)
|
||||
.then(cloudFoundryService.getServiceInstance(serviceInstanceName))
|
||||
.flatMap(serviceInstance -> {
|
||||
protected void createBackingServiceInstance(String serviceName, String planName, String serviceInstanceName,
|
||||
Map<String, Object> parameters) {
|
||||
this.cloudFoundryService.createBackingServiceInstance(planName, serviceName, serviceInstanceName, parameters)
|
||||
.then(this.cloudFoundryService.getServiceInstance(serviceInstanceName))
|
||||
.flatMap((serviceInstance) -> {
|
||||
assertThat(serviceInstance.getStatus())
|
||||
.withFailMessage("Create service instance failed:" + serviceInstance.getMessage())
|
||||
.isEqualTo("succeeded");
|
||||
@@ -320,9 +305,9 @@ abstract class CloudFoundryAcceptanceTest {
|
||||
}
|
||||
|
||||
protected void updateServiceInstance(String serviceInstanceName, Map<String, Object> parameters) {
|
||||
userCloudFoundryService.updateServiceInstance(serviceInstanceName, parameters)
|
||||
this.userCloudFoundryService.updateServiceInstance(serviceInstanceName, parameters)
|
||||
.then(getServiceInstanceMono(serviceInstanceName))
|
||||
.flatMap(serviceInstance -> {
|
||||
.flatMap((serviceInstance) -> {
|
||||
assertThat(serviceInstance.getStatus())
|
||||
.withFailMessage("Update service instance failed:" + serviceInstance.getMessage())
|
||||
.isEqualTo("succeeded");
|
||||
@@ -332,60 +317,56 @@ abstract class CloudFoundryAcceptanceTest {
|
||||
}
|
||||
|
||||
protected void deleteServiceInstance(String serviceInstanceName) {
|
||||
blockingSubscribe(userCloudFoundryService.deleteServiceInstance(serviceInstanceName));
|
||||
blockingSubscribe(this.userCloudFoundryService.deleteServiceInstance(serviceInstanceName));
|
||||
}
|
||||
|
||||
protected List<String> listServiceInstances() {
|
||||
return cloudFoundryService.listServiceInstances()
|
||||
return this.cloudFoundryService.listServiceInstances()
|
||||
.map(ServiceInstanceSummary::getName)
|
||||
.collectList()
|
||||
.block();
|
||||
}
|
||||
|
||||
protected ServiceInstance getBackingServiceInstance(String serviceInstanceName) {
|
||||
return cloudFoundryService.getServiceInstance(serviceInstanceName).block();
|
||||
return this.cloudFoundryService.getServiceInstance(serviceInstanceName).block();
|
||||
}
|
||||
|
||||
protected ServiceInstance getBackingServiceInstance(String serviceInstanceName, String space) {
|
||||
return cloudFoundryService.getServiceInstance(serviceInstanceName, space).block();
|
||||
return this.cloudFoundryService.getServiceInstance(serviceInstanceName, space).block();
|
||||
}
|
||||
|
||||
protected String getServiceInstanceGuid(String serviceInstanceName) {
|
||||
return getServiceInstanceMono(serviceInstanceName)
|
||||
.map(ServiceInstance::getId)
|
||||
.block();
|
||||
return getServiceInstanceMono(serviceInstanceName).map(ServiceInstance::getId).block();
|
||||
}
|
||||
|
||||
Mono<ServiceInstance> getServiceInstanceMono(String serviceInstanceName) {
|
||||
return userCloudFoundryService.getServiceInstance(serviceInstanceName);
|
||||
return this.userCloudFoundryService.getServiceInstance(serviceInstanceName);
|
||||
}
|
||||
|
||||
protected Optional<ApplicationSummary> getApplicationSummary(String appName) {
|
||||
return cloudFoundryService
|
||||
.getApplications()
|
||||
return this.cloudFoundryService.getApplications()
|
||||
.flatMapMany(Flux::fromIterable)
|
||||
.filter(applicationSummary -> appName.equals(applicationSummary.getName()))
|
||||
.filter((applicationSummary) -> appName.equals(applicationSummary.getName()))
|
||||
.next()
|
||||
.blockOptional();
|
||||
}
|
||||
|
||||
protected Optional<ApplicationDetail> getApplicationDetail(String appName) {
|
||||
return cloudFoundryService
|
||||
.getApplication(appName)
|
||||
.filter(applicationSummary -> appName.equals(applicationSummary.getName()))
|
||||
return this.cloudFoundryService.getApplication(appName)
|
||||
.filter((applicationSummary) -> appName.equals(applicationSummary.getName()))
|
||||
.blockOptional();
|
||||
}
|
||||
|
||||
protected Optional<ApplicationSummary> getApplicationSummary(String appName, String space) {
|
||||
return cloudFoundryService.getApplication(appName, space).blockOptional();
|
||||
return this.cloudFoundryService.getApplication(appName, space).blockOptional();
|
||||
}
|
||||
|
||||
private ApplicationEnvironments getApplicationEnvironment(String appName) {
|
||||
return cloudFoundryService.getApplicationEnvironment(appName).block();
|
||||
return this.cloudFoundryService.getApplicationEnvironment(appName).block();
|
||||
}
|
||||
|
||||
private ApplicationEnvironments getApplicationEnvironment(String appName, String space) {
|
||||
return cloudFoundryService.getApplicationEnvironment(appName, space).block();
|
||||
return this.cloudFoundryService.getApplicationEnvironment(appName, space).block();
|
||||
}
|
||||
|
||||
protected DocumentContext getSpringAppJson(String appName) {
|
||||
@@ -401,29 +382,28 @@ abstract class CloudFoundryAcceptanceTest {
|
||||
}
|
||||
|
||||
protected List<String> getSpaces() {
|
||||
return cloudFoundryService.getSpaces().block();
|
||||
return this.cloudFoundryService.getSpaces().block();
|
||||
}
|
||||
|
||||
protected Optional<GetClientResponse> getUaaClient(String clientId) {
|
||||
return uaaService.getUaaClient(clientId)
|
||||
.blockOptional();
|
||||
return this.uaaService.getUaaClient(clientId).blockOptional();
|
||||
}
|
||||
|
||||
protected void createDomain(String domain) {
|
||||
cloudFoundryService.createDomain(domain).block();
|
||||
this.cloudFoundryService.createDomain(domain).block();
|
||||
}
|
||||
|
||||
protected void deleteDomain(String domain) {
|
||||
cloudFoundryService.deleteDomain(domain).block();
|
||||
this.cloudFoundryService.deleteDomain(domain).block();
|
||||
}
|
||||
|
||||
private Path getTestBrokerAppPath() {
|
||||
return Paths.get(acceptanceTestProperties.getBrokerAppPath(), "");
|
||||
return Paths.get(this.acceptanceTestProperties.getBrokerAppPath(), "");
|
||||
}
|
||||
|
||||
private <T> void blockingSubscribe(Mono<? super T> publisher) {
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
publisher.subscribe(System.out::println, t -> {
|
||||
publisher.subscribe(System.out::println, (t) -> {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("error subscribing to publisher", t);
|
||||
}
|
||||
@@ -432,51 +412,39 @@ abstract class CloudFoundryAcceptanceTest {
|
||||
try {
|
||||
latch.await();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
catch (InterruptedException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected Mono<String> manageApps(String serviceInstanceName, String serviceName,
|
||||
String planName, String operation) {
|
||||
return userCloudFoundryService
|
||||
.getServiceInstance(serviceInstanceName)
|
||||
protected Mono<String> manageApps(String serviceInstanceName, String serviceName, String planName,
|
||||
String operation) {
|
||||
return this.userCloudFoundryService.getServiceInstance(serviceInstanceName)
|
||||
.map(ServiceInstance::getId)
|
||||
.flatMap(serviceInstanceId ->
|
||||
cloudFoundryService
|
||||
.getApplicationRoute(testBrokerAppName())
|
||||
.flatMap(appRoute ->
|
||||
webClient.get()
|
||||
.uri(URI.create(
|
||||
appRoute + "/" + operation + "/" + serviceName + "/" + planName + "/" + serviceInstanceId))
|
||||
.retrieve()
|
||||
.toEntity(String.class)
|
||||
.map(HttpEntity::getBody)));
|
||||
.flatMap((serviceInstanceId) -> this.cloudFoundryService.getApplicationRoute(testBrokerAppName())
|
||||
.flatMap((appRoute) -> this.webClient.get()
|
||||
.uri(URI.create(
|
||||
appRoute + "/" + operation + "/" + serviceName + "/" + planName + "/" + serviceInstanceId))
|
||||
.retrieve()
|
||||
.toEntity(String.class)
|
||||
.map(HttpEntity::getBody)));
|
||||
}
|
||||
|
||||
private WebClient getSslIgnoringWebClient() {
|
||||
return WebClient.builder()
|
||||
.clientConnector(new ReactorClientHttpConnector(HttpClient
|
||||
.create()
|
||||
.secure(t -> {
|
||||
try {
|
||||
t.sslContext(SslContextBuilder
|
||||
.forClient()
|
||||
.trustManager(InsecureTrustManagerFactory.INSTANCE)
|
||||
.build());
|
||||
}
|
||||
catch (SSLException e) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("problem ignoring SSL in WebClient", e);
|
||||
}
|
||||
}
|
||||
})))
|
||||
.build();
|
||||
return WebClient.builder().clientConnector(new ReactorClientHttpConnector(HttpClient.create().secure((t) -> {
|
||||
try {
|
||||
t.sslContext(SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build());
|
||||
}
|
||||
catch (SSLException ex) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("problem ignoring SSL in WebClient", ex);
|
||||
}
|
||||
}
|
||||
}))).build();
|
||||
}
|
||||
|
||||
protected Mono<List<ApplicationDetail>> getApplications(String app1, String app2) {
|
||||
return Flux.merge(cloudFoundryService.getApplication(app1),
|
||||
cloudFoundryService.getApplication(app2))
|
||||
return Flux.merge(this.cloudFoundryService.getApplication(app1), this.cloudFoundryService.getApplication(app2))
|
||||
.parallel()
|
||||
.runOn(Schedulers.parallel())
|
||||
.sequential()
|
||||
@@ -485,21 +453,17 @@ abstract class CloudFoundryAcceptanceTest {
|
||||
|
||||
private void prepareCLI() {
|
||||
try {
|
||||
cfHome = Files.createTempDirectory("app-broker-acceptance-tests").toString();
|
||||
this.cfHome = Files.createTempDirectory("app-broker-acceptance-tests").toString();
|
||||
|
||||
callCLICommand(List.of("cf", "login", "-a",
|
||||
cloudFoundryProperties.getApiHost(),
|
||||
"--skip-ssl-validation", "-u",
|
||||
cloudFoundryProperties.getUsername(),
|
||||
"-p",
|
||||
cloudFoundryProperties.getPassword(),
|
||||
"-o", "test-instances"))
|
||||
callCLICommand(List.of("cf", "login", "-a", this.cloudFoundryProperties.getApiHost(),
|
||||
"--skip-ssl-validation", "-u", this.cloudFoundryProperties.getUsername(), "-p",
|
||||
this.cloudFoundryProperties.getPassword(), "-o", "test-instances"))
|
||||
.block(Duration.ofSeconds(60));
|
||||
callCLICommand(List.of("cf", "install-plugin", "-f", "-r", "Cf-Community", "Service Instance Logging"))
|
||||
.block(Duration.ofSeconds(60));
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,7 +473,7 @@ abstract class CloudFoundryAcceptanceTest {
|
||||
LOG.debug("Executing command: {}", command);
|
||||
}
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(command);
|
||||
processBuilder.environment().put("CF_HOME", cfHome);
|
||||
processBuilder.environment().put("CF_HOME", this.cfHome);
|
||||
processBuilder.redirectErrorStream(true);
|
||||
Process process = processBuilder.start();
|
||||
|
||||
@@ -524,7 +488,7 @@ abstract class CloudFoundryAcceptanceTest {
|
||||
try {
|
||||
future.get(30, TimeUnit.SECONDS);
|
||||
}
|
||||
catch (TimeoutException e) {
|
||||
catch (TimeoutException ex) {
|
||||
LOG.info("Process reading timed out after 30 seconds");
|
||||
}
|
||||
finally {
|
||||
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class CreateInstanceAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
class CreateInstanceAcceptanceTests extends CloudFoundryAcceptanceTests {
|
||||
|
||||
private static final String APP_CREATE_1 = "app-create-1";
|
||||
|
||||
@@ -55,45 +55,39 @@ class CreateInstanceAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@AppBrokerTestProperties({
|
||||
"spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
@AppBrokerTestProperties({ "spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_CREATE_1,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_CREATE_1,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.ENV_VAR_1=value1",
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.ENV_VAR_2=value2",
|
||||
"spring.cloud.appbroker.services[0].apps[0].properties.memory=2G",
|
||||
"spring.cloud.appbroker.services[0].apps[0].properties.count=2",
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.ENV_VAR_1=value1",
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.ENV_VAR_2=value2",
|
||||
"spring.cloud.appbroker.services[0].apps[0].properties.memory=2G",
|
||||
"spring.cloud.appbroker.services[0].apps[0].properties.count=2",
|
||||
|
||||
"spring.cloud.appbroker.services[0].apps[1].name=" + APP_CREATE_2,
|
||||
"spring.cloud.appbroker.services[0].apps[1].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[1].name=" + APP_CREATE_2,
|
||||
"spring.cloud.appbroker.services[0].apps[1].path=" + BACKING_APP_PATH,
|
||||
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.properties.stack=cflinuxfs4"
|
||||
})
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.properties.stack=cflinuxfs4" })
|
||||
void deployAppsOnCreateService() {
|
||||
// when a service instance is created
|
||||
createServiceInstance(SI_NAME);
|
||||
|
||||
// then a backing applications are deployed
|
||||
Optional<ApplicationSummary> backingApplication1 = getApplicationSummary(APP_CREATE_1);
|
||||
assertThat(backingApplication1).hasValueSatisfying(app -> {
|
||||
assertThat(backingApplication1).hasValueSatisfying((app) -> {
|
||||
assertThat(app.getInstances()).isEqualTo(2);
|
||||
assertThat(app.getRunningInstances()).isGreaterThanOrEqualTo(1);
|
||||
assertThat(app.getMemoryLimit()).isEqualTo(2048);
|
||||
});
|
||||
|
||||
Optional<ApplicationSummary> backingApplication2 = getApplicationSummary(APP_CREATE_2);
|
||||
assertThat(backingApplication2).hasValueSatisfying(app ->
|
||||
assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
|
||||
assertThat(backingApplication2).hasValueSatisfying((app) -> assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
|
||||
// and stack is updated when specified
|
||||
Optional<ApplicationDetail> application1Detail = getApplicationDetail(APP_CREATE_1);
|
||||
assertThat(application1Detail).hasValueSatisfying(app -> {
|
||||
assertThat(app.getStack()).isEqualTo("cflinuxfs4");
|
||||
});
|
||||
assertThat(application1Detail).hasValueSatisfying((app) -> assertThat(app.getStack()).isEqualTo("cflinuxfs4"));
|
||||
|
||||
// and has the environment variables
|
||||
DocumentContext json = getSpringAppJson(APP_CREATE_1);
|
||||
@@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class CreateInstanceWithParametersAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
class CreateInstanceWithParametersAcceptanceTests extends CloudFoundryAcceptanceTests {
|
||||
|
||||
private static final String APP_NAME = "app-create-params";
|
||||
|
||||
@@ -54,19 +54,17 @@ class CreateInstanceWithParametersAcceptanceTest extends CloudFoundryAcceptanceT
|
||||
}
|
||||
|
||||
@Test
|
||||
@AppBrokerTestProperties({
|
||||
"spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.parameter1=config1",
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.parameter2=config2",
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.parameter3=config3",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[0].name=EnvironmentMapping",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[0].args.include=parameter1,parameter3",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[1].name=PropertyMapping",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[1].args.include=memory"
|
||||
})
|
||||
@AppBrokerTestProperties({ "spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.parameter1=config1",
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.parameter2=config2",
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.parameter3=config3",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[0].name=EnvironmentMapping",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[0].args.include=parameter1,parameter3",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[1].name=PropertyMapping",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[1].args.include=memory" })
|
||||
void deployAppsWithParametersOnCreateService() {
|
||||
// when a service instance is created
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
@@ -80,7 +78,7 @@ class CreateInstanceWithParametersAcceptanceTest extends CloudFoundryAcceptanceT
|
||||
|
||||
// then a backing application is deployed
|
||||
Optional<ApplicationSummary> backingApplication = getApplicationSummary(APP_NAME);
|
||||
assertThat(backingApplication).hasValueSatisfying(app -> {
|
||||
assertThat(backingApplication).hasValueSatisfying((app) -> {
|
||||
assertThat(app.getInstances()).isEqualTo(1);
|
||||
assertThat(app.getRunningInstances()).isEqualTo(1);
|
||||
assertThat(app.getMemoryLimit()).isEqualTo(2048);
|
||||
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.awaitility.Awaitility.await;
|
||||
|
||||
class CreateInstanceWithServiceInstanceGuidSuffixTargetAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
class CreateInstanceWithServiceInstanceGuidSuffixTargetAcceptanceTests extends CloudFoundryAcceptanceTests {
|
||||
|
||||
private static final String SUFFIX = "create-si-guid";
|
||||
|
||||
@@ -55,17 +55,15 @@ class CreateInstanceWithServiceInstanceGuidSuffixTargetAcceptanceTest extends Cl
|
||||
}
|
||||
|
||||
@Test
|
||||
@AppBrokerTestProperties({
|
||||
"spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME_1,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].services[0].service-instance-name=" + BACKING_SI_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].name=" + BACKING_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].plan=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].service-instance-name=" + BACKING_SI_NAME,
|
||||
"spring.cloud.appbroker.services[0].target.name=ServiceInstanceGuidSuffix"
|
||||
})
|
||||
@AppBrokerTestProperties({ "spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME_1,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].services[0].service-instance-name=" + BACKING_SI_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].name=" + BACKING_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].plan=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].service-instance-name=" + BACKING_SI_NAME,
|
||||
"spring.cloud.appbroker.services[0].target.name=ServiceInstanceGuidSuffix" })
|
||||
void deployAppsWithServiceInstanceGuidSuffixOnCreateService() {
|
||||
// when a service instance is created with target
|
||||
createServiceInstance(SI_NAME);
|
||||
@@ -73,11 +71,12 @@ class CreateInstanceWithServiceInstanceGuidSuffixTargetAcceptanceTest extends Cl
|
||||
// then backing application is created
|
||||
final String serviceInstanceGuid = getServiceInstanceGuid(SI_NAME);
|
||||
|
||||
// then backing application is named as the concatenation of the name and it's service instance id
|
||||
// then backing application is named as the concatenation of the name and it's
|
||||
// service instance id
|
||||
final String truncatedAppName = APP_NAME_1.substring(0, 13);
|
||||
final String expectedApplicationName = truncatedAppName + "-" + serviceInstanceGuid;
|
||||
Optional<ApplicationSummary> backingApplication = getApplicationSummary(expectedApplicationName);
|
||||
assertThat(backingApplication).hasValueSatisfying(app -> {
|
||||
assertThat(backingApplication).hasValueSatisfying((app) -> {
|
||||
assertThat(app.getName()).isEqualTo(expectedApplicationName);
|
||||
assertThat(app.getRunningInstances()).isEqualTo(1);
|
||||
});
|
||||
@@ -26,7 +26,7 @@ import static java.util.Collections.emptyMap;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.awaitility.Awaitility.await;
|
||||
|
||||
class CreateInstanceWithServicesAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
class CreateInstanceWithServicesAcceptanceTests extends CloudFoundryAcceptanceTests {
|
||||
|
||||
private static final String APP_NAME = "app-create-services";
|
||||
|
||||
@@ -58,17 +58,15 @@ class CreateInstanceWithServicesAcceptanceTest extends CloudFoundryAcceptanceTes
|
||||
}
|
||||
|
||||
@Test
|
||||
@AppBrokerTestProperties({
|
||||
"spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].services[0].service-instance-name=" + BACKING_SI_1_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].services[1].service-instance-name=" + BACKING_SI_2_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].name=" + BACKING_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].plan=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].service-instance-name=" + BACKING_SI_1_NAME
|
||||
})
|
||||
@AppBrokerTestProperties({ "spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].services[0].service-instance-name=" + BACKING_SI_1_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].services[1].service-instance-name=" + BACKING_SI_2_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].name=" + BACKING_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].plan=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].service-instance-name=" + BACKING_SI_1_NAME })
|
||||
void deployAppsAndCreateServicesOnCreateService() {
|
||||
// given that a service is available in the marketplace
|
||||
createBackingServiceInstance(BACKING_SERVICE_NAME, PLAN_NAME, BACKING_SI_2_NAME, emptyMap());
|
||||
@@ -78,8 +76,7 @@ class CreateInstanceWithServicesAcceptanceTest extends CloudFoundryAcceptanceTes
|
||||
|
||||
// then a backing application is deployed
|
||||
Optional<ApplicationSummary> backingApplication = getApplicationSummary(APP_NAME);
|
||||
assertThat(backingApplication).hasValueSatisfying(app ->
|
||||
assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
assertThat(backingApplication).hasValueSatisfying((app) -> assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
|
||||
// and the services are bound to it
|
||||
ServiceInstance serviceInstance1 = getBackingServiceInstance(BACKING_SI_1_NAME);
|
||||
@@ -95,12 +92,14 @@ class CreateInstanceWithServicesAcceptanceTest extends CloudFoundryAcceptanceTes
|
||||
await().untilAsserted(() -> assertThat(listServiceInstances()).doesNotContain(BACKING_SI_1_NAME));
|
||||
await().untilAsserted(() -> assertThat(listServiceInstances()).doesNotContain(BACKING_SI_2_NAME));
|
||||
|
||||
// TODO: another story to only remove the instances with service definition specified (https://github.com/spring-cloud/spring-cloud-app-broker/issues/316)
|
||||
// // service without specification has no applications bound to it
|
||||
// ServiceInstance serviceInstance2AfterDeletion = getServiceInstance(BACKING_SI_2_NAME);
|
||||
// assertThat(serviceInstance2AfterDeletion.getApplications()).isEmpty();
|
||||
//
|
||||
// deleteServiceInstance(BACKING_SI_2_NAME);
|
||||
// TODO: another story to only remove the instances with service definition
|
||||
// specified (https://github.com/spring-cloud/spring-cloud-app-broker/issues/316)
|
||||
// // service without specification has no applications bound to it
|
||||
// ServiceInstance serviceInstance2AfterDeletion =
|
||||
// getServiceInstance(BACKING_SI_2_NAME);
|
||||
// assertThat(serviceInstance2AfterDeletion.getApplications()).isEmpty();
|
||||
//
|
||||
// deleteServiceInstance(BACKING_SI_2_NAME);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,14 +25,20 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class CreateInstanceWithServicesSpacePerServiceInstanceTargetAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
class CreateInstanceWithServicesSpacePerServiceInstanceTargetAcceptanceTests extends CloudFoundryAcceptanceTests {
|
||||
|
||||
private static final String APP_NAME = "app-create-two-space-per";
|
||||
|
||||
private static final String SI_NAME = "si-create-two-space-per";
|
||||
|
||||
private static final String BACKING_SI_NAME_1 = "backing-service-two-space-per-target-1";
|
||||
|
||||
private static final String BACKING_SI_NAME_2 = "backing-service-two-space-per-target-2";
|
||||
|
||||
private static final String SUFFIX = "two-space-per-si";
|
||||
|
||||
private static final String APP_SERVICE_NAME = "app-service-" + SUFFIX;
|
||||
|
||||
private static final String BACKING_SERVICE_NAME = "backing-service-" + SUFFIX;
|
||||
|
||||
@Override
|
||||
@@ -51,33 +57,32 @@ class CreateInstanceWithServicesSpacePerServiceInstanceTargetAcceptanceTest exte
|
||||
}
|
||||
|
||||
@Test
|
||||
@AppBrokerTestProperties({
|
||||
"spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].target.name=SpacePerServiceInstance",
|
||||
@AppBrokerTestProperties({ "spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].target.name=SpacePerServiceInstance",
|
||||
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].services[0].service-instance-name=" + BACKING_SI_NAME_1,
|
||||
"spring.cloud.appbroker.services[0].apps[0].services[1].service-instance-name=" + BACKING_SI_NAME_2,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].services[0].service-instance-name=" + BACKING_SI_NAME_1,
|
||||
"spring.cloud.appbroker.services[0].apps[0].services[1].service-instance-name=" + BACKING_SI_NAME_2,
|
||||
|
||||
"spring.cloud.appbroker.services[0].services[0].name=" + BACKING_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].plan=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].service-instance-name=" + BACKING_SI_NAME_1,
|
||||
"spring.cloud.appbroker.services[0].services[0].name=" + BACKING_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].plan=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].service-instance-name=" + BACKING_SI_NAME_1,
|
||||
|
||||
"spring.cloud.appbroker.services[0].services[1].name=" + BACKING_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[1].plan=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[1].service-instance-name=" + BACKING_SI_NAME_2
|
||||
})
|
||||
"spring.cloud.appbroker.services[0].services[1].name=" + BACKING_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[1].plan=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[1].service-instance-name=" + BACKING_SI_NAME_2 })
|
||||
void deployAppsInTargetSpaceOnCreateService() {
|
||||
// when a service instance is created with targets
|
||||
createServiceInstance(SI_NAME);
|
||||
|
||||
// then backing applications are deployed in a space named as the service instance id
|
||||
// then backing applications are deployed in a space named as the service instance
|
||||
// id
|
||||
String spaceName = getServiceInstanceGuid(SI_NAME);
|
||||
|
||||
Optional<ApplicationSummary> backingApplication1 = getApplicationSummary(APP_NAME, spaceName);
|
||||
assertThat(backingApplication1).hasValueSatisfying(app -> {
|
||||
assertThat(backingApplication1).hasValueSatisfying((app) -> {
|
||||
assertThat(app.getRunningInstances()).isEqualTo(1);
|
||||
|
||||
// and has its route with the service instance id appended to it
|
||||
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class CreateInstanceWithSpacePerServiceInstanceTargetAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
class CreateInstanceWithSpacePerServiceInstanceTargetAcceptanceTests extends CloudFoundryAcceptanceTests {
|
||||
|
||||
private static final String APP_NAME_1 = "app-create-space-per1";
|
||||
|
||||
@@ -57,32 +57,31 @@ class CreateInstanceWithSpacePerServiceInstanceTargetAcceptanceTest extends Clou
|
||||
}
|
||||
|
||||
@Test
|
||||
@AppBrokerTestProperties({
|
||||
"spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
@AppBrokerTestProperties({ "spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME_1,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].services[0].service-instance-name=" + BACKING_SI_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME_1,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].services[0].service-instance-name=" + BACKING_SI_NAME,
|
||||
|
||||
"spring.cloud.appbroker.services[0].apps[1].name=" + APP_NAME_2,
|
||||
"spring.cloud.appbroker.services[0].apps[1].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[1].name=" + APP_NAME_2,
|
||||
"spring.cloud.appbroker.services[0].apps[1].path=" + BACKING_APP_PATH,
|
||||
|
||||
"spring.cloud.appbroker.services[0].services[0].name=" + BACKING_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].plan=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].service-instance-name=" + BACKING_SI_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].name=" + BACKING_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].plan=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].service-instance-name=" + BACKING_SI_NAME,
|
||||
|
||||
"spring.cloud.appbroker.services[0].target.name=SpacePerServiceInstance"
|
||||
})
|
||||
"spring.cloud.appbroker.services[0].target.name=SpacePerServiceInstance" })
|
||||
void deployAppsInTargetSpaceOnCreateService() {
|
||||
// when a service instance is created with targets
|
||||
createServiceInstance(SI_NAME);
|
||||
|
||||
// then backing applications are deployed in a space named as the service instance id
|
||||
// then backing applications are deployed in a space named as the service instance
|
||||
// id
|
||||
String spaceName = getServiceInstanceGuid(SI_NAME);
|
||||
|
||||
Optional<ApplicationSummary> backingApplication1 = getApplicationSummary(APP_NAME_1, spaceName);
|
||||
assertThat(backingApplication1).hasValueSatisfying(app -> {
|
||||
assertThat(backingApplication1).hasValueSatisfying((app) -> {
|
||||
assertThat(app.getRunningInstances()).isEqualTo(1);
|
||||
|
||||
// and has its route with the service instance id appended to it
|
||||
@@ -91,8 +90,7 @@ class CreateInstanceWithSpacePerServiceInstanceTargetAcceptanceTest extends Clou
|
||||
});
|
||||
|
||||
Optional<ApplicationSummary> backingApplication2 = getApplicationSummary(APP_NAME_2, spaceName);
|
||||
assertThat(backingApplication2).hasValueSatisfying(app ->
|
||||
assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
assertThat(backingApplication2).hasValueSatisfying((app) -> assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
|
||||
// and the services are bound to it
|
||||
ServiceInstance serviceInstance1 = getBackingServiceInstance(BACKING_SI_NAME, spaceName);
|
||||
@@ -44,55 +44,55 @@ class HealthListener {
|
||||
|
||||
private final RestTemplate restTemplate;
|
||||
|
||||
public HealthListener(RestTemplate restTemplate) {
|
||||
HealthListener(RestTemplate restTemplate) {
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
public void start(String path) {
|
||||
if (running.get()) {
|
||||
void start(String path) {
|
||||
if (this.running.get()) {
|
||||
throw new IllegalStateException("cannot start when test is already running");
|
||||
}
|
||||
requests.set(0);
|
||||
errors.set(0);
|
||||
running.set(true);
|
||||
this.requests.set(0);
|
||||
this.errors.set(0);
|
||||
this.running.set(true);
|
||||
|
||||
runner = new Thread(() -> {
|
||||
while (running.get()) {
|
||||
this.runner = new Thread(() -> {
|
||||
while (this.running.get()) {
|
||||
try {
|
||||
requests.incrementAndGet();
|
||||
ResponseEntity<String> response = restTemplate
|
||||
this.requests.incrementAndGet();
|
||||
ResponseEntity<String> response = this.restTemplate
|
||||
.getForEntity(URI.create("http://" + path + "/actuator/health"), String.class);
|
||||
if (response.getStatusCode() != HttpStatus.OK) {
|
||||
errors.incrementAndGet();
|
||||
this.errors.incrementAndGet();
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
catch (RestClientException | InterruptedException re) {
|
||||
errors.incrementAndGet();
|
||||
this.errors.incrementAndGet();
|
||||
}
|
||||
}
|
||||
});
|
||||
runner.start();
|
||||
this.runner.start();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
running.set(false);
|
||||
void stop() {
|
||||
this.running.set(false);
|
||||
try {
|
||||
runner.join();
|
||||
this.runner.join();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
catch (InterruptedException ex) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("thread was interrupted while waiting to die", e);
|
||||
LOG.debug("thread was interrupted while waiting to die", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getSuccesses() {
|
||||
return requests.get();
|
||||
int getSuccesses() {
|
||||
return this.requests.get();
|
||||
}
|
||||
|
||||
public int getFailures() {
|
||||
return errors.get();
|
||||
int getFailures() {
|
||||
return this.errors.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors
|
||||
* Copyright 2002-2020 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class LoggingRecentAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
class LoggingRecentAcceptanceTests extends CloudFoundryAcceptanceTests {
|
||||
|
||||
private static final String APP_CREATE_1 = "app-logging-recent-1";
|
||||
|
||||
@@ -52,19 +52,16 @@ class LoggingRecentAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@AppBrokerTestProperties({
|
||||
"spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_CREATE_1,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].target.name=SpacePerServiceInstance",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.properties.stack=cflinuxfs4"
|
||||
})
|
||||
@AppBrokerTestProperties({ "spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_CREATE_1,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].target.name=SpacePerServiceInstance",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.properties.stack=cflinuxfs4" })
|
||||
void shouldReturnBackingApplicationLogs() {
|
||||
createServiceInstance(SI_NAME);
|
||||
|
||||
String lines = callCLICommand(
|
||||
List.of("cf", "service-logs", SI_NAME, "--recent", "--skip-ssl-validation"))
|
||||
String lines = callCLICommand(List.of("cf", "service-logs", SI_NAME, "--recent", "--skip-ssl-validation"))
|
||||
.block(Duration.ofSeconds(35));
|
||||
|
||||
assertThat(lines).isNotEmpty();
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors
|
||||
* Copyright 2002-2020 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -28,7 +28,7 @@ import reactor.test.StepVerifier;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class LoggingStreamingAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
class LoggingStreamingAcceptanceTests extends CloudFoundryAcceptanceTests {
|
||||
|
||||
private static final String APP_CREATE_1 = "app-logging-stream-1";
|
||||
|
||||
@@ -56,30 +56,26 @@ class LoggingStreamingAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@AppBrokerTestProperties({
|
||||
"spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_CREATE_1,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].target.name=SpacePerServiceInstance",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.properties.stack=cflinuxfs4"
|
||||
})
|
||||
@AppBrokerTestProperties({ "spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_CREATE_1,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].target.name=SpacePerServiceInstance",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.properties.stack=cflinuxfs4" })
|
||||
void shouldStreamBackingApplicationLogs() {
|
||||
Mono<Object> createServiceInstanceMono = Mono.fromRunnable(() ->
|
||||
CompletableFuture.runAsync(() ->
|
||||
createServiceInstance(SI_NAME)))
|
||||
Mono<Object> createServiceInstanceMono = Mono
|
||||
.fromRunnable(() -> CompletableFuture.runAsync(() -> createServiceInstance(SI_NAME)))
|
||||
.subscribeOn(Schedulers.boundedElastic());
|
||||
|
||||
Mono<String> logStreamingMono = Mono.defer(() -> callCLICommand(
|
||||
List.of("cf", "service-logs", SI_NAME, "--skip-ssl-validation")
|
||||
)).subscribeOn(Schedulers.boundedElastic());
|
||||
Mono<String> logStreamingMono = Mono
|
||||
.defer(() -> callCLICommand(List.of("cf", "service-logs", SI_NAME, "--skip-ssl-validation")))
|
||||
.subscribeOn(Schedulers.boundedElastic());
|
||||
|
||||
StepVerifier.create(createServiceInstanceMono
|
||||
.then(Mono.delay(Duration.ofSeconds(20)).then())
|
||||
StepVerifier
|
||||
.create(createServiceInstanceMono.then(Mono.delay(Duration.ofSeconds(20)).then())
|
||||
.then(getServiceInstanceMono(SI_NAME).retry(5))
|
||||
.then(Mono.zip(logStreamingMono, logStreamingMono))
|
||||
)
|
||||
.assertNext(tuple -> {
|
||||
.then(Mono.zip(logStreamingMono, logStreamingMono)))
|
||||
.assertNext((tuple) -> {
|
||||
assertThat(tuple.getT1()).isNotEmpty();
|
||||
assertThat(tuple.getT1()).contains("Connected, tailing logs for service instance");
|
||||
assertThat(tuple.getT1()).contains("[STG/0]");
|
||||
@@ -28,7 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class UpdateInstanceAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
class UpdateInstanceAcceptanceTests extends CloudFoundryAcceptanceTests {
|
||||
|
||||
private static final String APP_NAME = "app-update";
|
||||
|
||||
@@ -59,28 +59,25 @@ class UpdateInstanceAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@AppBrokerTestProperties({
|
||||
"spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.parameter1=config1",
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.parameter2=config2",
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.parameter3=config3",
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.parameter4=config4",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[0].name=EnvironmentMapping",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[0].args.include=parameter1,parameter3",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[1].name=PropertyMapping",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[1].args.include=count"
|
||||
})
|
||||
@AppBrokerTestProperties({ "spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.parameter1=config1",
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.parameter2=config2",
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.parameter3=config3",
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.parameter4=config4",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[0].name=EnvironmentMapping",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[0].args.include=parameter1,parameter3",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[1].name=PropertyMapping",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[1].args.include=count" })
|
||||
void deployAppsOnUpdateService() {
|
||||
// given a service instance is created
|
||||
createServiceInstance(SI_NAME);
|
||||
|
||||
// and a backing application is deployed
|
||||
Optional<ApplicationSummary> backingApplication = getApplicationSummary(APP_NAME);
|
||||
assertThat(backingApplication).hasValueSatisfying(app ->
|
||||
assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
assertThat(backingApplication).hasValueSatisfying((app) -> assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
|
||||
DocumentContext json = getSpringAppJson(APP_NAME);
|
||||
assertThat(json.read("$.parameter1").toString()).isEqualTo("config1");
|
||||
@@ -88,7 +85,7 @@ class UpdateInstanceAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
assertThat(json.read("$.parameter3").toString()).isEqualTo("config3");
|
||||
|
||||
String path = backingApplication.get().getUrls().get(0);
|
||||
healthListener.start(path);
|
||||
this.healthListener.start(path);
|
||||
|
||||
// when the service instance is updated
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
@@ -99,9 +96,9 @@ class UpdateInstanceAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
updateServiceInstance(SI_NAME, parameters);
|
||||
|
||||
// then the backing application was updated with zero downtime
|
||||
healthListener.stop();
|
||||
assertThat(healthListener.getFailures()).isEqualTo(0);
|
||||
assertThat(healthListener.getSuccesses()).isGreaterThan(0);
|
||||
this.healthListener.stop();
|
||||
assertThat(this.healthListener.getFailures()).isEqualTo(0);
|
||||
assertThat(this.healthListener.getSuccesses()).isGreaterThan(0);
|
||||
|
||||
// the backing application is updated with the new parameters
|
||||
json = getSpringAppJson(APP_NAME);
|
||||
@@ -111,8 +108,7 @@ class UpdateInstanceAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
assertThat(json.read("$.parameter4").toString()).isEqualTo("config4");
|
||||
|
||||
backingApplication = getApplicationSummary(APP_NAME);
|
||||
assertThat(backingApplication).hasValueSatisfying(app ->
|
||||
assertThat(app.getRunningInstances()).isEqualTo(2));
|
||||
assertThat(backingApplication).hasValueSatisfying((app) -> assertThat(app.getRunningInstances()).isEqualTo(2));
|
||||
|
||||
// when the service instance is deleted
|
||||
deleteServiceInstance(SI_NAME);
|
||||
@@ -27,7 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class UpdateInstanceWithHostAndDomainAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
class UpdateInstanceWithHostAndDomainAcceptanceTests extends CloudFoundryAcceptanceTests {
|
||||
|
||||
private static final String APP_NAME = "app-update-domain";
|
||||
|
||||
@@ -58,26 +58,23 @@ class UpdateInstanceWithHostAndDomainAcceptanceTest extends CloudFoundryAcceptan
|
||||
}
|
||||
|
||||
@Test
|
||||
@AppBrokerTestProperties({
|
||||
"spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
@AppBrokerTestProperties({ "spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[0].name=PropertyMapping",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[0].args.include=host,domain"
|
||||
})
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[0].name=PropertyMapping",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[0].args.include=host,domain" })
|
||||
void deployAppsOnUpdateService() {
|
||||
// given a service instance is created
|
||||
createServiceInstance(SI_NAME);
|
||||
|
||||
// and a backing application is deployed
|
||||
Optional<ApplicationSummary> backingApplication = getApplicationSummary(APP_NAME);
|
||||
assertThat(backingApplication).hasValueSatisfying(app ->
|
||||
assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
assertThat(backingApplication).hasValueSatisfying((app) -> assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
|
||||
String path = backingApplication.get().getUrls().get(0);
|
||||
healthListener.start(path);
|
||||
this.healthListener.start(path);
|
||||
|
||||
// and the domain exists
|
||||
createDomain("mydomain.com");
|
||||
@@ -89,13 +86,13 @@ class UpdateInstanceWithHostAndDomainAcceptanceTest extends CloudFoundryAcceptan
|
||||
updateServiceInstance(SI_NAME, parameters);
|
||||
|
||||
// then the backing application was updated with zero downtime
|
||||
healthListener.stop();
|
||||
assertThat(healthListener.getFailures()).isEqualTo(0);
|
||||
assertThat(healthListener.getSuccesses()).isGreaterThan(0);
|
||||
this.healthListener.stop();
|
||||
assertThat(this.healthListener.getFailures()).isEqualTo(0);
|
||||
assertThat(this.healthListener.getSuccesses()).isGreaterThan(0);
|
||||
|
||||
backingApplication = getApplicationSummary(APP_NAME);
|
||||
assertThat(backingApplication).hasValueSatisfying(app ->
|
||||
assertThat(app.getUrls()).contains("myhost.mydomain.com"));
|
||||
assertThat(backingApplication)
|
||||
.hasValueSatisfying((app) -> assertThat(app.getUrls()).contains("myhost.mydomain.com"));
|
||||
|
||||
// when the service instance is deleted
|
||||
deleteServiceInstance(SI_NAME);
|
||||
@@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.awaitility.Awaitility.await;
|
||||
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class UpdateInstanceWithNewServiceAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
class UpdateInstanceWithNewServiceAcceptanceTests extends CloudFoundryAcceptanceTests {
|
||||
|
||||
private static final String APP_NAME = "app-update-with-new-services";
|
||||
|
||||
@@ -56,7 +56,6 @@ class UpdateInstanceWithNewServiceAcceptanceTest extends CloudFoundryAcceptanceT
|
||||
|
||||
private static final String BACKING_SERVICE_NAME = "backing-service-" + SUFFIX;
|
||||
|
||||
|
||||
@Autowired
|
||||
private HealthListener healthListener;
|
||||
|
||||
@@ -78,63 +77,58 @@ class UpdateInstanceWithNewServiceAcceptanceTest extends CloudFoundryAcceptanceT
|
||||
@Test
|
||||
@Tag("first")
|
||||
@Order(FIRST_TEST)
|
||||
@AppBrokerTestProperties({
|
||||
"spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
@AppBrokerTestProperties({ "spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].services[0].service-instance-name=" + OLD_BACKING_SI_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].services[0].service-instance-name=" + OLD_BACKING_SI_NAME,
|
||||
|
||||
"spring.cloud.appbroker.services[0].services[0].name=" + BACKING_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].plan=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].service-instance-name=" + OLD_BACKING_SI_NAME
|
||||
})
|
||||
"spring.cloud.appbroker.services[0].services[0].name=" + BACKING_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].plan=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].service-instance-name=" + OLD_BACKING_SI_NAME })
|
||||
void weCreateAService() {
|
||||
// when a service instance is created
|
||||
createServiceInstance(SI_NAME);
|
||||
|
||||
// then a backing application is deployed
|
||||
Optional<ApplicationSummary> backingApplication = getApplicationSummary(APP_NAME);
|
||||
assertThat(backingApplication).hasValueSatisfying(app ->
|
||||
assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
assertThat(backingApplication).hasValueSatisfying((app) -> assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
|
||||
// and the services are bound to it
|
||||
ServiceInstance backingServiceInstance = getBackingServiceInstance(OLD_BACKING_SI_NAME);
|
||||
assertThat(backingServiceInstance.getApplications()).contains(APP_NAME);
|
||||
|
||||
String path = backingApplication.get().getUrls().get(0);
|
||||
healthListener.start(path);
|
||||
this.healthListener.start(path);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(SECOND_TEST)
|
||||
@Tag("last")
|
||||
@AppBrokerTestProperties({
|
||||
"spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
@AppBrokerTestProperties({ "spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].services[0].service-instance-name=" + NEW_BACKING_SI_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].services[0].service-instance-name=" + NEW_BACKING_SI_NAME,
|
||||
|
||||
"spring.cloud.appbroker.services[0].services[0].name=" + BACKING_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].plan=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].service-instance-name=" + NEW_BACKING_SI_NAME
|
||||
})
|
||||
"spring.cloud.appbroker.services[0].services[0].name=" + BACKING_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].plan=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].service-instance-name=" + NEW_BACKING_SI_NAME })
|
||||
void weUpdateTheServiceInstanceWithANewBackingService() {
|
||||
// when the service instance is updated with a new service
|
||||
updateServiceInstance(SI_NAME, Collections.emptyMap());
|
||||
|
||||
// then the backing application was updated with zero downtime
|
||||
healthListener.stop();
|
||||
assertThat(healthListener.getFailures()).isEqualTo(0);
|
||||
assertThat(healthListener.getSuccesses()).isGreaterThan(0);
|
||||
this.healthListener.stop();
|
||||
assertThat(this.healthListener.getFailures()).isEqualTo(0);
|
||||
assertThat(this.healthListener.getSuccesses()).isGreaterThan(0);
|
||||
|
||||
// then a backing application is re-deployed
|
||||
Optional<ApplicationSummary> updatedBackingApplication = getApplicationSummary(APP_NAME);
|
||||
assertThat(updatedBackingApplication).hasValueSatisfying(app ->
|
||||
assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
assertThat(updatedBackingApplication)
|
||||
.hasValueSatisfying((app) -> assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
|
||||
// and the new backing service is bound to it
|
||||
ServiceInstance newBackingServiceInstance = getBackingServiceInstance(NEW_BACKING_SI_NAME);
|
||||
@@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.awaitility.Awaitility.await;
|
||||
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class UpdateInstanceWithNewServiceAndTargetAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
class UpdateInstanceWithNewServiceAndTargetAcceptanceTests extends CloudFoundryAcceptanceTests {
|
||||
|
||||
private static final String APP_NAME = "app-new-service";
|
||||
|
||||
@@ -56,7 +56,6 @@ class UpdateInstanceWithNewServiceAndTargetAcceptanceTest extends CloudFoundryAc
|
||||
|
||||
private static final String BACKING_SERVICE_NAME = "backing-service-" + SUFFIX;
|
||||
|
||||
|
||||
@Autowired
|
||||
private HealthListener healthListener;
|
||||
|
||||
@@ -78,20 +77,18 @@ class UpdateInstanceWithNewServiceAndTargetAcceptanceTest extends CloudFoundryAc
|
||||
@Test
|
||||
@Tag("first")
|
||||
@Order(FIRST_TEST)
|
||||
@AppBrokerTestProperties({
|
||||
"spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
@AppBrokerTestProperties({ "spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].services[0].service-instance-name=" + OLD_BACKING_SI_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].services[0].service-instance-name=" + OLD_BACKING_SI_NAME,
|
||||
|
||||
"spring.cloud.appbroker.services[0].services[0].name=" + BACKING_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].plan=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].service-instance-name=" + OLD_BACKING_SI_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].name=" + BACKING_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].plan=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].service-instance-name=" + OLD_BACKING_SI_NAME,
|
||||
|
||||
"spring.cloud.appbroker.services[0].target.name=SpacePerServiceInstance"
|
||||
})
|
||||
"spring.cloud.appbroker.services[0].target.name=SpacePerServiceInstance" })
|
||||
void weCreateAService() {
|
||||
// when a service instance is created
|
||||
createServiceInstance(SI_NAME);
|
||||
@@ -100,47 +97,45 @@ class UpdateInstanceWithNewServiceAndTargetAcceptanceTest extends CloudFoundryAc
|
||||
String spaceName = getServiceInstanceGuid(SI_NAME);
|
||||
|
||||
Optional<ApplicationSummary> backingApplication = getApplicationSummary(APP_NAME, spaceName);
|
||||
assertThat(backingApplication).hasValueSatisfying(app -> assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
assertThat(backingApplication).hasValueSatisfying((app) -> assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
|
||||
// and the services are bound to it
|
||||
ServiceInstance backingServiceInstance = getBackingServiceInstance(OLD_BACKING_SI_NAME, spaceName);
|
||||
assertThat(backingServiceInstance.getApplications()).contains(APP_NAME);
|
||||
|
||||
String path = backingApplication.get().getUrls().get(0);
|
||||
healthListener.start(path);
|
||||
this.healthListener.start(path);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(SECOND_TEST)
|
||||
@Tag("last")
|
||||
@AppBrokerTestProperties({
|
||||
"spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
@AppBrokerTestProperties({ "spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].services[0].service-instance-name=" + NEW_BACKING_SI_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].services[0].service-instance-name=" + NEW_BACKING_SI_NAME,
|
||||
|
||||
"spring.cloud.appbroker.services[0].services[0].name=" + BACKING_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].plan=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].service-instance-name=" + NEW_BACKING_SI_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].name=" + BACKING_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].plan=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].service-instance-name=" + NEW_BACKING_SI_NAME,
|
||||
|
||||
"spring.cloud.appbroker.services[0].target.name=SpacePerServiceInstance"
|
||||
})
|
||||
"spring.cloud.appbroker.services[0].target.name=SpacePerServiceInstance" })
|
||||
void weUpdateTheServiceInstanceWithANewBackingService() {
|
||||
// when the service instance is updated with a new service
|
||||
updateServiceInstance(SI_NAME, Collections.emptyMap());
|
||||
String spaceName = getServiceInstanceGuid(SI_NAME);
|
||||
|
||||
// then the backing application was updated with zero downtime
|
||||
healthListener.stop();
|
||||
assertThat(healthListener.getFailures()).isEqualTo(0);
|
||||
assertThat(healthListener.getSuccesses()).isGreaterThan(0);
|
||||
this.healthListener.stop();
|
||||
assertThat(this.healthListener.getFailures()).isEqualTo(0);
|
||||
assertThat(this.healthListener.getSuccesses()).isGreaterThan(0);
|
||||
|
||||
// then a backing application is re-deployed
|
||||
Optional<ApplicationSummary> updatedBackingApplication = getApplicationSummary(APP_NAME, spaceName);
|
||||
assertThat(updatedBackingApplication).hasValueSatisfying(app ->
|
||||
assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
assertThat(updatedBackingApplication)
|
||||
.hasValueSatisfying((app) -> assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
|
||||
// and the new backing service is bound to it
|
||||
ServiceInstance newBackingServiceInstance = getBackingServiceInstance(NEW_BACKING_SI_NAME, spaceName);
|
||||
@@ -29,7 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.awaitility.Awaitility.await;
|
||||
|
||||
class UpdateInstanceWithServicesAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
class UpdateInstanceWithServicesAcceptanceTests extends CloudFoundryAcceptanceTests {
|
||||
|
||||
private static final String APP_NAME = "app-update-services";
|
||||
|
||||
@@ -62,34 +62,31 @@ class UpdateInstanceWithServicesAcceptanceTest extends CloudFoundryAcceptanceTes
|
||||
}
|
||||
|
||||
@Test
|
||||
@AppBrokerTestProperties({
|
||||
"spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
@AppBrokerTestProperties({ "spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].services[0].service-instance-name=" + BACKING_SI_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].services[0].service-instance-name=" + BACKING_SI_NAME,
|
||||
|
||||
"spring.cloud.appbroker.services[0].services[0].name=" + BACKING_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].plan=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].service-instance-name=" + BACKING_SI_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].rebind-on-update=true"
|
||||
})
|
||||
"spring.cloud.appbroker.services[0].services[0].name=" + BACKING_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].plan=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].service-instance-name=" + BACKING_SI_NAME,
|
||||
"spring.cloud.appbroker.services[0].services[0].rebind-on-update=true" })
|
||||
void shouldPushAppWithServicesBind() {
|
||||
// when a service instance is created
|
||||
createServiceInstance(SI_NAME);
|
||||
|
||||
// then a backing application is deployed
|
||||
Optional<ApplicationSummary> backingApplication = getApplicationSummary(APP_NAME);
|
||||
assertThat(backingApplication).hasValueSatisfying(app ->
|
||||
assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
assertThat(backingApplication).hasValueSatisfying((app) -> assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
|
||||
// and the services are bound to it
|
||||
ServiceInstance backingServiceInstance = getBackingServiceInstance(BACKING_SI_NAME);
|
||||
assertThat(backingServiceInstance.getApplications()).contains(APP_NAME);
|
||||
|
||||
String path = backingApplication.get().getUrls().get(0);
|
||||
healthListener.start(path);
|
||||
this.healthListener.start(path);
|
||||
|
||||
// when the service instance is updated
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
@@ -99,14 +96,14 @@ class UpdateInstanceWithServicesAcceptanceTest extends CloudFoundryAcceptanceTes
|
||||
updateServiceInstance(SI_NAME, parameters);
|
||||
|
||||
// then the backing application was updated with zero downtime
|
||||
healthListener.stop();
|
||||
assertThat(healthListener.getFailures()).isEqualTo(0);
|
||||
assertThat(healthListener.getSuccesses()).isGreaterThan(0);
|
||||
this.healthListener.stop();
|
||||
assertThat(this.healthListener.getFailures()).isEqualTo(0);
|
||||
assertThat(this.healthListener.getSuccesses()).isGreaterThan(0);
|
||||
|
||||
// then a backing application is re-deployed
|
||||
Optional<ApplicationSummary> updatedBackingApplication = getApplicationSummary(APP_NAME);
|
||||
assertThat(updatedBackingApplication).hasValueSatisfying(app ->
|
||||
assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
assertThat(updatedBackingApplication)
|
||||
.hasValueSatisfying((app) -> assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
|
||||
// and the services are still bound to it
|
||||
ServiceInstance backingServiceInstanceUpdated = getBackingServiceInstance(BACKING_SI_NAME);
|
||||
@@ -28,7 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class UpdateInstanceWithTargetAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
class UpdateInstanceWithTargetAcceptanceTests extends CloudFoundryAcceptanceTests {
|
||||
|
||||
private static final String APP_NAME = "app-update-target";
|
||||
|
||||
@@ -59,25 +59,24 @@ class UpdateInstanceWithTargetAcceptanceTest extends CloudFoundryAcceptanceTest
|
||||
}
|
||||
|
||||
@Test
|
||||
@AppBrokerTestProperties({
|
||||
"spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
@AppBrokerTestProperties({ "spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.parameter1=config1",
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.parameter1=config1",
|
||||
|
||||
"spring.cloud.appbroker.services[0].target.name=SpacePerServiceInstance"
|
||||
})
|
||||
"spring.cloud.appbroker.services[0].target.name=SpacePerServiceInstance" })
|
||||
void deployAppsInTargetSpaceOnUpdateService() {
|
||||
// when a service instance is created
|
||||
createServiceInstance(SI_NAME);
|
||||
|
||||
// then a backing application is deployed in a space named as the service instance id
|
||||
// then a backing application is deployed in a space named as the service instance
|
||||
// id
|
||||
String spaceName = getServiceInstanceGuid(SI_NAME);
|
||||
|
||||
Optional<ApplicationSummary> backingApplication = getApplicationSummary(APP_NAME, spaceName);
|
||||
assertThat(backingApplication).hasValueSatisfying(app -> {
|
||||
assertThat(backingApplication).hasValueSatisfying((app) -> {
|
||||
assertThat(app.getRunningInstances()).isEqualTo(1);
|
||||
|
||||
// and has its route with the service instance id appended to it
|
||||
@@ -86,15 +85,15 @@ class UpdateInstanceWithTargetAcceptanceTest extends CloudFoundryAcceptanceTest
|
||||
});
|
||||
|
||||
String path = backingApplication.get().getUrls().get(0);
|
||||
healthListener.start(path);
|
||||
this.healthListener.start(path);
|
||||
|
||||
// when the service instance is updated
|
||||
updateServiceInstance(SI_NAME, Collections.singletonMap("parameter2", "config2"));
|
||||
|
||||
// then the backing application was updated with zero downtime
|
||||
healthListener.stop();
|
||||
assertThat(healthListener.getFailures()).isEqualTo(0);
|
||||
assertThat(healthListener.getSuccesses()).isGreaterThan(0);
|
||||
this.healthListener.stop();
|
||||
assertThat(this.healthListener.getFailures()).isEqualTo(0);
|
||||
assertThat(this.healthListener.getSuccesses()).isGreaterThan(0);
|
||||
|
||||
// then the service instance has the initial parameters
|
||||
DocumentContext json = getSpringAppJson(APP_NAME, spaceName);
|
||||
@@ -36,7 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class UpgradeInstanceAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
class UpgradeInstanceAcceptanceTests extends CloudFoundryAcceptanceTests {
|
||||
|
||||
private static final String APP_NAME = "app-upgrade";
|
||||
|
||||
@@ -73,24 +73,21 @@ class UpgradeInstanceAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
@Test
|
||||
@Tag("first")
|
||||
@Order(FIRST_TEST)
|
||||
@AppBrokerTestProperties({
|
||||
"spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.parameter1=old-config1",
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.parameter2=old-config2",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[0].name=PropertyMapping",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[0].args.include=upgrade"
|
||||
})
|
||||
@AppBrokerTestProperties({ "spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.parameter1=old-config1",
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.parameter2=old-config2",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[0].name=PropertyMapping",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[0].args.include=upgrade" })
|
||||
void createsServiceInstance() {
|
||||
// when a service instance is created
|
||||
createServiceInstance(SI_NAME);
|
||||
|
||||
// then a backing application is deployed
|
||||
Optional<ApplicationSummary> backingApplication = getApplicationSummary(APP_NAME);
|
||||
assertThat(backingApplication).hasValueSatisfying(app ->
|
||||
assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
assertThat(backingApplication).hasValueSatisfying((app) -> assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
|
||||
// and the environment variables are applied correctly
|
||||
DocumentContext json = getSpringAppJson(APP_NAME);
|
||||
@@ -98,31 +95,29 @@ class UpgradeInstanceAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
assertThat(json.read("$.parameter2").toString()).isEqualTo("old-config2");
|
||||
|
||||
String path = backingApplication.get().getUrls().get(0);
|
||||
healthListener.start(path);
|
||||
this.healthListener.start(path);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(SECOND_TEST)
|
||||
@Tag("last")
|
||||
@AppBrokerTestProperties({
|
||||
"spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.parameter1=new-config1",
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.parameter3=new-config3",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[0].name=PropertyMapping",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[0].args.include=upgrade",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.properties.stack=cflinuxfs4"
|
||||
})
|
||||
@AppBrokerTestProperties({ "spring.cloud.appbroker.services[0].service-name=" + APP_SERVICE_NAME,
|
||||
"spring.cloud.appbroker.services[0].plan-name=" + PLAN_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].name=" + APP_NAME,
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=" + BACKING_APP_PATH,
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.parameter1=new-config1",
|
||||
"spring.cloud.appbroker.services[0].apps[0].environment.parameter3=new-config3",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[0].name=PropertyMapping",
|
||||
"spring.cloud.appbroker.services[0].apps[0].parameters-transformers[0].args.include=upgrade",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.properties.stack=cflinuxfs4" })
|
||||
void upgradesTheServiceInstanceWithNewBackingServiceAndEnvironmentVariables() {
|
||||
// when the service instance is updated with a new service
|
||||
updateServiceInstance(SI_NAME, Collections.singletonMap("upgrade", true));
|
||||
|
||||
// then a backing application is re-deployed
|
||||
Optional<ApplicationSummary> updatedBackingApplication = getApplicationSummary(APP_NAME);
|
||||
assertThat(updatedBackingApplication).hasValueSatisfying(app ->
|
||||
assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
assertThat(updatedBackingApplication)
|
||||
.hasValueSatisfying((app) -> assertThat(app.getRunningInstances()).isEqualTo(1));
|
||||
|
||||
// the backing application is updated with the new parameters
|
||||
DocumentContext json = getSpringAppJson(APP_NAME);
|
||||
@@ -132,14 +127,12 @@ class UpgradeInstanceAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
|
||||
// and stack is updated when specified
|
||||
Optional<ApplicationDetail> application1Detail = getApplicationDetail(APP_NAME);
|
||||
assertThat(application1Detail).hasValueSatisfying(app -> {
|
||||
assertThat(app.getStack()).isEqualTo("cflinuxfs4");
|
||||
});
|
||||
assertThat(application1Detail).hasValueSatisfying((app) -> assertThat(app.getStack()).isEqualTo("cflinuxfs4"));
|
||||
|
||||
// then the backing application was updated with zero downtime
|
||||
healthListener.stop();
|
||||
assertThat(healthListener.getFailures()).isEqualTo(0);
|
||||
assertThat(healthListener.getSuccesses()).isGreaterThan(0);
|
||||
this.healthListener.stop();
|
||||
assertThat(this.healthListener.getFailures()).isEqualTo(0);
|
||||
assertThat(this.healthListener.getSuccesses()).isGreaterThan(0);
|
||||
|
||||
// when the service instance is deleted
|
||||
deleteServiceInstance(SI_NAME);
|
||||
@@ -167,4 +160,5 @@ class UpgradeInstanceAcceptanceTest extends CloudFoundryAcceptanceTest {
|
||||
super.tearDown(testInfo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -45,18 +45,17 @@ import org.springframework.context.annotation.Configuration;
|
||||
public class CloudFoundryClientConfiguration {
|
||||
|
||||
/**
|
||||
* The broker client secret
|
||||
* Please note that acceptance tests setup would not recreate the client if client id or authorities doesn't change.
|
||||
* Manual environment clean up is needed on existing test environments if secret changes are necessary.
|
||||
* The broker client secret Please note that acceptance tests setup would not recreate
|
||||
* the client if client id or authorities doesn't change. Manual environment clean up
|
||||
* is needed on existing test environments if secret changes are necessary.
|
||||
*/
|
||||
public static final String APP_BROKER_CLIENT_SECRET = "app-broker-client-secret";
|
||||
|
||||
/**
|
||||
* The broker client authorities
|
||||
*/
|
||||
public static final String[] APP_BROKER_CLIENT_AUTHORITIES = {
|
||||
"cloud_controller.read", "cloud_controller.write", "clients.write"
|
||||
};
|
||||
public static final String[] APP_BROKER_CLIENT_AUTHORITIES = { "cloud_controller.read", "cloud_controller.write",
|
||||
"clients.write" };
|
||||
|
||||
/**
|
||||
* The user client id
|
||||
@@ -64,24 +63,20 @@ public class CloudFoundryClientConfiguration {
|
||||
public static final String USER_CLIENT_ID = "app-broker-user-client";
|
||||
|
||||
/**
|
||||
* The user client secret
|
||||
* Please note that acceptance tests setup would not recreate the client if client id or authorities doesn't change.
|
||||
* Manual environment clean up is needed on existing test environments if secret changes are necessary.
|
||||
* The user client secret Please note that acceptance tests setup would not recreate
|
||||
* the client if client id or authorities doesn't change. Manual environment clean up
|
||||
* is needed on existing test environments if secret changes are necessary.
|
||||
*/
|
||||
public static final String USER_CLIENT_SECRET = "app-broker-user-client-secret";
|
||||
|
||||
/**
|
||||
* The user client authorities
|
||||
*/
|
||||
public static final String[] USER_CLIENT_AUTHORITIES = {
|
||||
"cloud_controller.read", "cloud_controller.write"
|
||||
};
|
||||
public static final String[] USER_CLIENT_AUTHORITIES = { "cloud_controller.read", "cloud_controller.write" };
|
||||
|
||||
@Bean
|
||||
protected CloudFoundryOperations cloudFoundryOperations(CloudFoundryProperties properties,
|
||||
CloudFoundryClient client,
|
||||
DopplerClient dopplerClient,
|
||||
@Qualifier("userCredentials") UaaClient uaaClient) {
|
||||
CloudFoundryClient client, DopplerClient dopplerClient, @Qualifier("userCredentials") UaaClient uaaClient) {
|
||||
return DefaultCloudFoundryOperations.builder()
|
||||
.cloudFoundryClient(client)
|
||||
.dopplerClient(dopplerClient)
|
||||
@@ -93,7 +88,7 @@ public class CloudFoundryClientConfiguration {
|
||||
|
||||
@Bean
|
||||
protected CloudFoundryClient cloudFoundryClient(ConnectionContext connectionContext,
|
||||
@Qualifier("userCredentials") TokenProvider tokenProvider) {
|
||||
@Qualifier("userCredentials") TokenProvider tokenProvider) {
|
||||
return ReactorCloudFoundryClient.builder()
|
||||
.connectionContext(connectionContext)
|
||||
.tokenProvider(tokenProvider)
|
||||
@@ -112,16 +107,13 @@ public class CloudFoundryClientConfiguration {
|
||||
|
||||
@Bean
|
||||
protected DopplerClient dopplerClient(ConnectionContext connectionContext,
|
||||
@Qualifier("userCredentials") TokenProvider tokenProvider) {
|
||||
return ReactorDopplerClient.builder()
|
||||
.connectionContext(connectionContext)
|
||||
.tokenProvider(tokenProvider)
|
||||
.build();
|
||||
@Qualifier("userCredentials") TokenProvider tokenProvider) {
|
||||
return ReactorDopplerClient.builder().connectionContext(connectionContext).tokenProvider(tokenProvider).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
protected LogCacheClient logCacheClient(ConnectionContext connectionContext,
|
||||
@Qualifier("userCredentials") TokenProvider tokenProvider) {
|
||||
@Qualifier("userCredentials") TokenProvider tokenProvider) {
|
||||
return ReactorLogCacheClient.builder()
|
||||
.connectionContext(connectionContext)
|
||||
.tokenProvider(tokenProvider)
|
||||
@@ -131,29 +123,21 @@ public class CloudFoundryClientConfiguration {
|
||||
@Bean
|
||||
@Qualifier("userCredentials")
|
||||
protected UaaClient userCredentialsUaaClient(ConnectionContext connectionContext,
|
||||
@Qualifier("userCredentials") TokenProvider tokenProvider) {
|
||||
return ReactorUaaClient.builder()
|
||||
.connectionContext(connectionContext)
|
||||
.tokenProvider(tokenProvider)
|
||||
.build();
|
||||
@Qualifier("userCredentials") TokenProvider tokenProvider) {
|
||||
return ReactorUaaClient.builder().connectionContext(connectionContext).tokenProvider(tokenProvider).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Qualifier("clientCredentials")
|
||||
protected UaaClient clientCredentialsUaaClient(ConnectionContext connectionContext,
|
||||
@Qualifier("clientCredentials") TokenProvider tokenProvider) {
|
||||
return ReactorUaaClient.builder()
|
||||
.connectionContext(connectionContext)
|
||||
.tokenProvider(tokenProvider)
|
||||
.build();
|
||||
@Qualifier("clientCredentials") TokenProvider tokenProvider) {
|
||||
return ReactorUaaClient.builder().connectionContext(connectionContext).tokenProvider(tokenProvider).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Qualifier("userCredentials")
|
||||
@ConditionalOnProperty({
|
||||
CloudFoundryProperties.PROPERTY_PREFIX + ".username",
|
||||
CloudFoundryProperties.PROPERTY_PREFIX + ".password"
|
||||
})
|
||||
@ConditionalOnProperty({ CloudFoundryProperties.PROPERTY_PREFIX + ".username",
|
||||
CloudFoundryProperties.PROPERTY_PREFIX + ".password" })
|
||||
protected PasswordGrantTokenProvider passwordTokenProvider(CloudFoundryProperties properties) {
|
||||
return PasswordGrantTokenProvider.builder()
|
||||
.password(properties.getPassword())
|
||||
@@ -163,10 +147,8 @@ public class CloudFoundryClientConfiguration {
|
||||
|
||||
@Bean
|
||||
@Qualifier("clientCredentials")
|
||||
@ConditionalOnProperty({
|
||||
CloudFoundryProperties.PROPERTY_PREFIX + ".client-id",
|
||||
CloudFoundryProperties.PROPERTY_PREFIX + ".client-secret"
|
||||
})
|
||||
@ConditionalOnProperty({ CloudFoundryProperties.PROPERTY_PREFIX + ".client-id",
|
||||
CloudFoundryProperties.PROPERTY_PREFIX + ".client-secret" })
|
||||
protected ClientCredentialsGrantTokenProvider clientTokenProvider(CloudFoundryProperties properties) {
|
||||
return ClientCredentialsGrantTokenProvider.builder()
|
||||
.clientId(properties.getClientId())
|
||||
|
||||
@@ -16,23 +16,20 @@
|
||||
|
||||
package org.springframework.cloud.appbroker.acceptance.fixtures.cf;
|
||||
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import org.cloudfoundry.reactor.ProxyConfiguration;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import static org.springframework.cloud.appbroker.acceptance.fixtures.cf.CloudFoundryProperties.PROPERTY_PREFIX;
|
||||
|
||||
@ConfigurationProperties(PROPERTY_PREFIX)
|
||||
@ConfigurationProperties(CloudFoundryProperties.PROPERTY_PREFIX)
|
||||
@Validated
|
||||
public class CloudFoundryProperties {
|
||||
|
||||
protected static final String PROPERTY_PREFIX = "spring.cloud.appbroker.acceptancetest.cloudfoundry";
|
||||
protected static final String PROPERTY_PREFIX = "spring.cloud.appbroker.acceptancetest" + ".cloudfoundry";
|
||||
|
||||
@NotBlank
|
||||
private String apiHost;
|
||||
@@ -65,7 +62,7 @@ public class CloudFoundryProperties {
|
||||
private boolean skipSslValidation;
|
||||
|
||||
public String getApiHost() {
|
||||
return apiHost;
|
||||
return this.apiHost;
|
||||
}
|
||||
|
||||
public void setApiHost(String apiHost) {
|
||||
@@ -73,7 +70,7 @@ public class CloudFoundryProperties {
|
||||
}
|
||||
|
||||
public Integer getApiPort() {
|
||||
return apiPort;
|
||||
return this.apiPort;
|
||||
}
|
||||
|
||||
public void setApiPort(int apiPort) {
|
||||
@@ -81,7 +78,7 @@ public class CloudFoundryProperties {
|
||||
}
|
||||
|
||||
public String getDefaultOrg() {
|
||||
return defaultOrg;
|
||||
return this.defaultOrg;
|
||||
}
|
||||
|
||||
public void setDefaultOrg(String defaultOrg) {
|
||||
@@ -89,7 +86,7 @@ public class CloudFoundryProperties {
|
||||
}
|
||||
|
||||
public String getDefaultSpace() {
|
||||
return defaultSpace;
|
||||
return this.defaultSpace;
|
||||
}
|
||||
|
||||
public void setDefaultSpace(String defaultSpace) {
|
||||
@@ -97,7 +94,7 @@ public class CloudFoundryProperties {
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
@@ -105,7 +102,7 @@ public class CloudFoundryProperties {
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
return this.password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
@@ -113,7 +110,7 @@ public class CloudFoundryProperties {
|
||||
}
|
||||
|
||||
public String getClientId() {
|
||||
return clientId;
|
||||
return this.clientId;
|
||||
}
|
||||
|
||||
public void setClientId(String clientId) {
|
||||
@@ -121,7 +118,7 @@ public class CloudFoundryProperties {
|
||||
}
|
||||
|
||||
public String getClientSecret() {
|
||||
return clientSecret;
|
||||
return this.clientSecret;
|
||||
}
|
||||
|
||||
public void setClientSecret(String clientSecret) {
|
||||
@@ -129,7 +126,7 @@ public class CloudFoundryProperties {
|
||||
}
|
||||
|
||||
public String getIdentityZoneSubdomain() {
|
||||
return identityZoneSubdomain;
|
||||
return this.identityZoneSubdomain;
|
||||
}
|
||||
|
||||
public void setIdentityZoneSubdomain(String identityZoneSubdomain) {
|
||||
@@ -141,7 +138,7 @@ public class CloudFoundryProperties {
|
||||
}
|
||||
|
||||
public boolean isSecure() {
|
||||
return secure;
|
||||
return this.secure;
|
||||
}
|
||||
|
||||
public void setSecure(boolean secure) {
|
||||
@@ -149,7 +146,7 @@ public class CloudFoundryProperties {
|
||||
}
|
||||
|
||||
public boolean isSkipSslValidation() {
|
||||
return skipSslValidation;
|
||||
return this.skipSslValidation;
|
||||
}
|
||||
|
||||
public void setSkipSslValidation(boolean skipSslValidation) {
|
||||
@@ -158,7 +155,7 @@ public class CloudFoundryProperties {
|
||||
|
||||
private static String parseApiHost(String api) {
|
||||
final URI uri = URI.create(api);
|
||||
return uri.getHost() == null ? api : uri.getHost();
|
||||
return (uri.getHost() == null) ? api : uri.getHost();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -88,179 +88,173 @@ public class CloudFoundryService {
|
||||
|
||||
private final CloudFoundryProperties cloudFoundryProperties;
|
||||
|
||||
public CloudFoundryService(
|
||||
CloudFoundryClient cloudFoundryClient,
|
||||
CloudFoundryOperations cloudFoundryOperations,
|
||||
CloudFoundryProperties cloudFoundryProperties) {
|
||||
public CloudFoundryService(CloudFoundryClient cloudFoundryClient, CloudFoundryOperations cloudFoundryOperations,
|
||||
CloudFoundryProperties cloudFoundryProperties) {
|
||||
this.cloudFoundryClient = cloudFoundryClient;
|
||||
this.cloudFoundryOperations = cloudFoundryOperations;
|
||||
this.cloudFoundryProperties = cloudFoundryProperties;
|
||||
}
|
||||
|
||||
public Mono<Void> enableServiceBrokerAccess(String serviceName) {
|
||||
return cloudFoundryOperations.serviceAdmin().enableServiceAccess(EnableServiceAccessRequest.builder()
|
||||
.serviceName(serviceName)
|
||||
.build())
|
||||
.doOnSuccess(v -> LOG.info("Enabled access to service. serviceName={}", serviceName))
|
||||
.doOnError(e -> LOG.error(String.format("Error enabling access to service. serviceName=%s, error=%s",
|
||||
serviceName, e.getMessage()), e));
|
||||
return this.cloudFoundryOperations.serviceAdmin()
|
||||
.enableServiceAccess(EnableServiceAccessRequest.builder().serviceName(serviceName).build())
|
||||
.doOnSuccess((v) -> LOG.info("Enabled access to service. serviceName={}", serviceName))
|
||||
.doOnError((e) -> LOG.error(String.format("Error enabling access to service. serviceName=%s, error=%s",
|
||||
serviceName, e.getMessage()), e));
|
||||
}
|
||||
|
||||
public Mono<Void> createServiceBroker(String brokerName, String testBrokerAppName) {
|
||||
return getApplicationRoute(testBrokerAppName)
|
||||
.flatMap(url -> cloudFoundryOperations.serviceAdmin().create(CreateServiceBrokerRequest.builder()
|
||||
return getApplicationRoute(testBrokerAppName).flatMap((url) -> this.cloudFoundryOperations.serviceAdmin()
|
||||
.create(CreateServiceBrokerRequest.builder()
|
||||
.name(brokerName)
|
||||
.username("user")
|
||||
.password("password")
|
||||
.url(url)
|
||||
.build())
|
||||
.doOnSuccess(v -> LOG.info("Success creating service broker. brokerName={}", brokerName))
|
||||
.doOnError(e -> LOG.error(String.format("Error creating service broker. brokerName=%s, error=%s",
|
||||
brokerName, e.getMessage()), e)));
|
||||
.doOnSuccess((v) -> LOG.info("Success creating service broker. brokerName={}", brokerName))
|
||||
.doOnError((e) -> LOG.error(
|
||||
String.format("Error creating service broker. brokerName=%s, error=%s", brokerName, e.getMessage()),
|
||||
e)));
|
||||
}
|
||||
|
||||
public Mono<Void> updateServiceBroker(String brokerName, String testBrokerAppName) {
|
||||
return getApplicationRoute(testBrokerAppName)
|
||||
.flatMap(url -> cloudFoundryOperations.serviceAdmin().update(UpdateServiceBrokerRequest.builder()
|
||||
return getApplicationRoute(testBrokerAppName).flatMap((url) -> this.cloudFoundryOperations.serviceAdmin()
|
||||
.update(UpdateServiceBrokerRequest.builder()
|
||||
.name(brokerName)
|
||||
.username("user")
|
||||
.password("password")
|
||||
.url(url)
|
||||
.build())
|
||||
.doOnSuccess(v -> LOG.info("Success updating service broker. brokerName={}", brokerName))
|
||||
.doOnError(e -> LOG.error(String.format("Error updating service broker. brokerName=%s, error=%s",
|
||||
brokerName, e.getMessage()), e)));
|
||||
.doOnSuccess((v) -> LOG.info("Success updating service broker. brokerName={}", brokerName))
|
||||
.doOnError((e) -> LOG.error(
|
||||
String.format("Error updating service broker. brokerName=%s, error=%s", brokerName, e.getMessage()),
|
||||
e)));
|
||||
}
|
||||
|
||||
public Mono<String> getApplicationRoute(String appName) {
|
||||
return cloudFoundryOperations.applications().get(GetApplicationRequest.builder()
|
||||
.name(appName)
|
||||
.build())
|
||||
.doOnSuccess(item -> LOG.info("Success getting route for app. appName={}", appName))
|
||||
.doOnError(e -> LOG.error(String.format("Error getting route for app. appName=%s, error=%s", appName,
|
||||
e.getMessage()), e))
|
||||
return this.cloudFoundryOperations.applications()
|
||||
.get(GetApplicationRequest.builder().name(appName).build())
|
||||
.doOnSuccess((item) -> LOG.info("Success getting route for app. appName={}", appName))
|
||||
.doOnError((e) -> LOG
|
||||
.error(String.format("Error getting route for app. appName=%s, error=%s", appName, e.getMessage()), e))
|
||||
.map(ApplicationDetail::getUrls)
|
||||
.flatMapMany(Flux::fromIterable)
|
||||
.next()
|
||||
.map(url -> "https://" + url);
|
||||
.map((url) -> "https://" + url);
|
||||
}
|
||||
|
||||
public Mono<Void> pushBrokerApp(String appName, Path appPath, String brokerClientId,
|
||||
List<String> appBrokerProperties) {
|
||||
return cloudFoundryOperations.applications().pushManifest(PushApplicationManifestRequest.builder()
|
||||
.manifest(ApplicationManifest.builder()
|
||||
.environmentVariables(appBrokerDeployerEnvironmentVariables(brokerClientId))
|
||||
.putAllEnvironmentVariables(propertiesToEnvironment(appBrokerProperties))
|
||||
.name(appName)
|
||||
.path(appPath)
|
||||
.memory(1024)
|
||||
List<String> appBrokerProperties) {
|
||||
return this.cloudFoundryOperations.applications()
|
||||
.pushManifest(PushApplicationManifestRequest.builder()
|
||||
.manifest(ApplicationManifest.builder()
|
||||
.environmentVariables(appBrokerDeployerEnvironmentVariables(brokerClientId))
|
||||
.putAllEnvironmentVariables(propertiesToEnvironment(appBrokerProperties))
|
||||
.name(appName)
|
||||
.path(appPath)
|
||||
.memory(1024)
|
||||
.build())
|
||||
.build())
|
||||
.build())
|
||||
.doOnSuccess(v -> LOG.info("Success pushing broker app. appName={}", appName))
|
||||
.doOnError(e -> LOG.error(String.format("Error pushing broker app. appName=%s, error=%s", appName,
|
||||
e.getMessage()), e));
|
||||
.doOnSuccess((v) -> LOG.info("Success pushing broker app. appName={}", appName))
|
||||
.doOnError((e) -> LOG
|
||||
.error(String.format("Error pushing broker app. appName=%s, error=%s", appName, e.getMessage()), e));
|
||||
}
|
||||
|
||||
public Mono<Void> updateBrokerApp(String appName, String brokerClientId, List<String> appBrokerProperties) {
|
||||
return cloudFoundryOperations.applications().get(GetApplicationRequest.builder().name(appName).build())
|
||||
return this.cloudFoundryOperations.applications()
|
||||
.get(GetApplicationRequest.builder().name(appName).build())
|
||||
.map(ApplicationDetail::getId)
|
||||
.flatMap(applicationId -> cloudFoundryClient.applicationsV2().update(UpdateApplicationRequest
|
||||
.builder()
|
||||
.applicationId(applicationId)
|
||||
.putAllEnvironmentJsons(appBrokerDeployerEnvironmentVariables(brokerClientId))
|
||||
.putAllEnvironmentJsons(propertiesToEnvironment(appBrokerProperties))
|
||||
.name(appName)
|
||||
.memory(1024)
|
||||
.build())
|
||||
.flatMap((applicationId) -> this.cloudFoundryClient.applicationsV2()
|
||||
.update(UpdateApplicationRequest.builder()
|
||||
.applicationId(applicationId)
|
||||
.putAllEnvironmentJsons(appBrokerDeployerEnvironmentVariables(brokerClientId))
|
||||
.putAllEnvironmentJsons(propertiesToEnvironment(appBrokerProperties))
|
||||
.name(appName)
|
||||
.memory(1024)
|
||||
.build())
|
||||
.thenReturn(applicationId))
|
||||
.then(cloudFoundryOperations.applications().restart(RestartApplicationRequest.builder()
|
||||
.name(appName)
|
||||
.build()))
|
||||
.doOnSuccess(item -> LOG.info("Updated broker app " + appName))
|
||||
.doOnError(error -> LOG.error("Error updating broker app " + appName + ": " + error))
|
||||
.then(this.cloudFoundryOperations.applications()
|
||||
.restart(RestartApplicationRequest.builder().name(appName).build()))
|
||||
.doOnSuccess((item) -> LOG.info("Updated broker app " + appName))
|
||||
.doOnError((error) -> LOG.error("Error updating broker app " + appName + ": " + error))
|
||||
.then();
|
||||
}
|
||||
|
||||
public Mono<Void> deleteApp(String appName) {
|
||||
return cloudFoundryOperations.applications().list()
|
||||
.filter(app -> appName.equals(app.getName()))
|
||||
return this.cloudFoundryOperations.applications()
|
||||
.list()
|
||||
.filter((app) -> appName.equals(app.getName()))
|
||||
.singleOrEmpty()
|
||||
.flatMap(app -> cloudFoundryOperations.applications().delete(DeleteApplicationRequest.builder()
|
||||
.name(appName)
|
||||
.deleteRoutes(true)
|
||||
.build()))
|
||||
.doOnSuccess(item -> LOG.info("Success deleting app. appName={}", appName))
|
||||
.doOnError(e -> LOG.warn(String.format("Error deleting app. appName=%s, error=%s", appName,
|
||||
e.getMessage()), e))
|
||||
.onErrorResume(e -> Mono.empty());
|
||||
.flatMap((app) -> this.cloudFoundryOperations.applications()
|
||||
.delete(DeleteApplicationRequest.builder().name(appName).deleteRoutes(true).build()))
|
||||
.doOnSuccess((item) -> LOG.info("Success deleting app. appName={}", appName))
|
||||
.doOnError((e) -> LOG
|
||||
.warn(String.format("Error deleting app. appName=%s, error=%s", appName, e.getMessage()), e))
|
||||
.onErrorResume((e) -> Mono.empty());
|
||||
}
|
||||
|
||||
public Mono<Void> deleteServiceBroker(String brokerName) {
|
||||
return cloudFoundryOperations.serviceAdmin().list()
|
||||
.filter(serviceBroker -> brokerName.equals(serviceBroker.getName()))
|
||||
return this.cloudFoundryOperations.serviceAdmin()
|
||||
.list()
|
||||
.filter((serviceBroker) -> brokerName.equals(serviceBroker.getName()))
|
||||
.singleOrEmpty()
|
||||
.flatMap(serviceBroker -> cloudFoundryOperations.serviceAdmin()
|
||||
.delete(DeleteServiceBrokerRequest.builder().name(brokerName).build())
|
||||
)
|
||||
.doOnSuccess(item -> LOG.info("Success deleting service broker. brokerName={}", brokerName))
|
||||
.doOnError(e -> LOG.warn(String.format("Error deleting service broker. brokerName=%s, error=%s ",
|
||||
brokerName, e.getMessage()), e))
|
||||
.onErrorResume(e -> Mono.empty());
|
||||
.flatMap((serviceBroker) -> this.cloudFoundryOperations.serviceAdmin()
|
||||
.delete(DeleteServiceBrokerRequest.builder().name(brokerName).build()))
|
||||
.doOnSuccess((item) -> LOG.info("Success deleting service broker. brokerName={}", brokerName))
|
||||
.doOnError((e) -> LOG.warn(String.format("Error deleting service broker. brokerName=%s, error=%s ",
|
||||
brokerName, e.getMessage()), e))
|
||||
.onErrorResume((e) -> Mono.empty());
|
||||
}
|
||||
|
||||
public Mono<Void> createBackingServiceInstance(String planName,
|
||||
String serviceName,
|
||||
String serviceInstanceName,
|
||||
Map<String, Object> parameters) {
|
||||
return cloudFoundryOperations.services().createInstance(CreateServiceInstanceRequest.builder()
|
||||
.planName(planName)
|
||||
.serviceName(serviceName)
|
||||
.serviceInstanceName(serviceInstanceName)
|
||||
.parameters(parameters)
|
||||
.build())
|
||||
.doOnSuccess(item -> LOG.info("Success creating service instance. serviceInstanceName={}",
|
||||
serviceInstanceName))
|
||||
.doOnError(e -> LOG.error(String.format("Error creating service instance. serviceInstanceName=%s, " +
|
||||
"error=%s", serviceInstanceName, e.getMessage()), e));
|
||||
public Mono<Void> createBackingServiceInstance(String planName, String serviceName, String serviceInstanceName,
|
||||
Map<String, Object> parameters) {
|
||||
return this.cloudFoundryOperations.services()
|
||||
.createInstance(CreateServiceInstanceRequest.builder()
|
||||
.planName(planName)
|
||||
.serviceName(serviceName)
|
||||
.serviceInstanceName(serviceInstanceName)
|
||||
.parameters(parameters)
|
||||
.build())
|
||||
.doOnSuccess((item) -> LOG.info("Success creating service instance. serviceInstanceName={}",
|
||||
serviceInstanceName))
|
||||
.doOnError((e) -> LOG
|
||||
.error(String.format("Error creating service instance. serviceInstanceName=%s, " + "error=%s",
|
||||
serviceInstanceName, e.getMessage()), e));
|
||||
}
|
||||
|
||||
public Flux<ServiceInstanceSummary> listServiceInstances() {
|
||||
return cloudFoundryOperations.services().listInstances();
|
||||
return this.cloudFoundryOperations.services().listInstances();
|
||||
}
|
||||
|
||||
public Mono<ServiceInstance> getServiceInstance(String serviceInstanceName) {
|
||||
return getServiceInstance(cloudFoundryOperations, serviceInstanceName);
|
||||
return getServiceInstance(this.cloudFoundryOperations, serviceInstanceName);
|
||||
}
|
||||
|
||||
public Mono<ServiceInstance> getServiceInstance(String serviceInstanceName, String space) {
|
||||
return getServiceInstance(createOperationsForSpace(space), serviceInstanceName);
|
||||
}
|
||||
|
||||
private Mono<ServiceInstance> getServiceInstance(CloudFoundryOperations operations,
|
||||
String serviceInstanceName) {
|
||||
return operations.services().getInstance(GetServiceInstanceRequest.builder()
|
||||
.name(serviceInstanceName)
|
||||
.build())
|
||||
.doOnSuccess(item -> LOG.info("Success getting service instance. serviceInstanceName={}",
|
||||
serviceInstanceName))
|
||||
.doOnError(e -> LOG.error(String.format("Error getting service instance. serviceInstanceName=%s, " +
|
||||
"error=%s", serviceInstanceName, e.getMessage()), e));
|
||||
private Mono<ServiceInstance> getServiceInstance(CloudFoundryOperations operations, String serviceInstanceName) {
|
||||
return operations.services()
|
||||
.getInstance(GetServiceInstanceRequest.builder().name(serviceInstanceName).build())
|
||||
.doOnSuccess(
|
||||
(item) -> LOG.info("Success getting service instance. serviceInstanceName={}", serviceInstanceName))
|
||||
.doOnError((e) -> LOG
|
||||
.error(String.format("Error getting service instance. serviceInstanceName=%s, " + "error=%s",
|
||||
serviceInstanceName, e.getMessage()), e));
|
||||
}
|
||||
|
||||
public Mono<List<ApplicationSummary>> getApplications() {
|
||||
return listApplications(cloudFoundryOperations)
|
||||
.collectList();
|
||||
return listApplications(this.cloudFoundryOperations).collectList();
|
||||
}
|
||||
|
||||
public Mono<ApplicationDetail> getApplication(String appName) {
|
||||
return cloudFoundryOperations.applications().get(GetApplicationRequest.builder()
|
||||
.name(appName)
|
||||
.build());
|
||||
return this.cloudFoundryOperations.applications().get(GetApplicationRequest.builder().name(appName).build());
|
||||
}
|
||||
|
||||
public Mono<ApplicationSummary> getApplication(String appName, String space) {
|
||||
return listApplications(createOperationsForSpace(space))
|
||||
.filter(applicationSummary -> applicationSummary.getName().equals(appName))
|
||||
.filter((applicationSummary) -> applicationSummary.getName().equals(appName))
|
||||
.single();
|
||||
}
|
||||
|
||||
@@ -268,11 +262,11 @@ public class CloudFoundryService {
|
||||
return operations.applications()
|
||||
.list()
|
||||
.doOnComplete(() -> LOG.info("Listed applications"))
|
||||
.doOnError(e -> LOG.error(String.format("Error listing applications. error=%s", e.getMessage()), e));
|
||||
.doOnError((e) -> LOG.error(String.format("Error listing applications. error=%s", e.getMessage()), e));
|
||||
}
|
||||
|
||||
public Mono<ApplicationEnvironments> getApplicationEnvironment(String appName) {
|
||||
return getApplicationEnvironment(cloudFoundryOperations, appName);
|
||||
return getApplicationEnvironment(this.cloudFoundryOperations, appName);
|
||||
}
|
||||
|
||||
public Mono<ApplicationEnvironments> getApplicationEnvironment(String appName, String space) {
|
||||
@@ -281,32 +275,31 @@ public class CloudFoundryService {
|
||||
|
||||
private Mono<ApplicationEnvironments> getApplicationEnvironment(CloudFoundryOperations operations, String appName) {
|
||||
return operations.applications()
|
||||
.getEnvironments(GetApplicationEnvironmentsRequest.builder()
|
||||
.name(appName)
|
||||
.build())
|
||||
.doOnSuccess(item -> LOG.info("Success getting environment for application. appName={}", appName))
|
||||
.doOnError(e -> LOG.error(String.format("Error getting environment for application. appName=%s, " +
|
||||
"error=%s", appName, e.getMessage()), e));
|
||||
.getEnvironments(GetApplicationEnvironmentsRequest.builder().name(appName).build())
|
||||
.doOnSuccess((item) -> LOG.info("Success getting environment for application. appName={}", appName))
|
||||
.doOnError((e) -> LOG
|
||||
.error(String.format("Error getting environment for application. appName=%s, " + "error=%s", appName,
|
||||
e.getMessage()), e));
|
||||
}
|
||||
|
||||
public Mono<Void> stopApplication(String appName) {
|
||||
return cloudFoundryOperations.applications().stop(StopApplicationRequest.builder()
|
||||
.name(appName)
|
||||
.build());
|
||||
return this.cloudFoundryOperations.applications().stop(StopApplicationRequest.builder().name(appName).build());
|
||||
}
|
||||
|
||||
public Mono<SpaceSummary> getOrCreateDefaultSpace() {
|
||||
return getOrCreateSpace(cloudFoundryProperties.getDefaultOrg(), cloudFoundryProperties.getDefaultSpace());
|
||||
return getOrCreateSpace(this.cloudFoundryProperties.getDefaultOrg(),
|
||||
this.cloudFoundryProperties.getDefaultSpace());
|
||||
}
|
||||
|
||||
public Mono<OrganizationSummary> getOrCreateDefaultOrg() {
|
||||
return getOrCreateOrganization(cloudFoundryProperties.getDefaultOrg());
|
||||
return getOrCreateOrganization(this.cloudFoundryProperties.getDefaultOrg());
|
||||
}
|
||||
|
||||
public Mono<List<String>> getSpaces() {
|
||||
return cloudFoundryOperations.spaces().list()
|
||||
return this.cloudFoundryOperations.spaces()
|
||||
.list()
|
||||
.doOnComplete(() -> LOG.info("Success listing spaces"))
|
||||
.doOnError(e -> LOG.error(String.format("Error listing spaces. error=%s", e.getMessage()), e))
|
||||
.doOnError((e) -> LOG.error(String.format("Error listing spaces. error=%s", e.getMessage()), e))
|
||||
.map(SpaceSummary::getName)
|
||||
.collectList();
|
||||
}
|
||||
@@ -318,132 +311,98 @@ public class CloudFoundryService {
|
||||
.build()
|
||||
.spaces();
|
||||
|
||||
return getSpace(spaceOperations, spaceName).switchIfEmpty(spaceOperations.create(CreateSpaceRequest.builder()
|
||||
.name(spaceName)
|
||||
.organization(orgName)
|
||||
.build())
|
||||
.then(getSpace(spaceOperations, spaceName)));
|
||||
return getSpace(spaceOperations, spaceName).switchIfEmpty(
|
||||
spaceOperations.create(CreateSpaceRequest.builder().name(spaceName).organization(orgName).build())
|
||||
.then(getSpace(spaceOperations, spaceName)));
|
||||
}
|
||||
|
||||
public Mono<OrganizationSummary> getOrCreateOrganization(String orgName) {
|
||||
Organizations organizationOperations = cloudFoundryOperations.organizations();
|
||||
Organizations organizationOperations = this.cloudFoundryOperations.organizations();
|
||||
|
||||
return getOrg(organizationOperations, orgName)
|
||||
.switchIfEmpty(organizationOperations.create(CreateOrganizationRequest.builder()
|
||||
.organizationName(orgName)
|
||||
.build())
|
||||
.then(getOrg(organizationOperations, orgName)));
|
||||
return getOrg(organizationOperations, orgName).switchIfEmpty(
|
||||
organizationOperations.create(CreateOrganizationRequest.builder().organizationName(orgName).build())
|
||||
.then(getOrg(organizationOperations, orgName)));
|
||||
}
|
||||
|
||||
private Mono<OrganizationSummary> getOrg(Organizations orgOperations, String orgName) {
|
||||
return orgOperations.list()
|
||||
.filter(r -> r
|
||||
.getName()
|
||||
.equals(orgName))
|
||||
.next();
|
||||
return orgOperations.list().filter((r) -> r.getName().equals(orgName)).next();
|
||||
}
|
||||
|
||||
private Mono<SpaceSummary> getSpace(Spaces spaceOperations, String spaceName) {
|
||||
return spaceOperations.list()
|
||||
.filter(r -> r
|
||||
.getName()
|
||||
.equals(spaceName))
|
||||
.next();
|
||||
return spaceOperations.list().filter((r) -> r.getName().equals(spaceName)).next();
|
||||
}
|
||||
|
||||
public Mono<Void> associateAppBrokerClientWithOrgAndSpace(String brokerClientId, String orgId, String spaceId) {
|
||||
return Mono.justOrEmpty(brokerClientId)
|
||||
.flatMap(userId -> associateOrgUser(orgId, userId)
|
||||
.then(associateOrgManager(orgId, userId))
|
||||
.flatMap((userId) -> associateOrgUser(orgId, userId).then(associateOrgManager(orgId, userId))
|
||||
.then(associateSpaceDeveloper(spaceId, userId)))
|
||||
.then();
|
||||
}
|
||||
|
||||
public Mono<Void> associateClientWithOrgAndSpace(String clientId, String orgId, String spaceId) {
|
||||
return associateOrgUser(orgId, clientId)
|
||||
.then(associateSpaceDeveloper(spaceId, clientId))
|
||||
.then();
|
||||
return associateOrgUser(orgId, clientId).then(associateSpaceDeveloper(spaceId, clientId)).then();
|
||||
}
|
||||
|
||||
public Mono<Void> removeAppBrokerClientFromOrgAndSpace(String brokerClientId, String orgId, String spaceId) {
|
||||
return Mono.justOrEmpty(brokerClientId)
|
||||
.flatMap(userId -> removeSpaceDeveloper(spaceId, userId)
|
||||
.then(removeOrgManager(orgId, userId))
|
||||
.flatMap((userId) -> removeSpaceDeveloper(spaceId, userId).then(removeOrgManager(orgId, userId))
|
||||
.then(removeOrgUser(orgId, userId)));
|
||||
}
|
||||
|
||||
public Mono<Void> createDomain(String domain) {
|
||||
return cloudFoundryOperations
|
||||
.domains()
|
||||
.create(CreateDomainRequest
|
||||
.builder()
|
||||
return this.cloudFoundryOperations.domains()
|
||||
.create(CreateDomainRequest.builder()
|
||||
.domain(domain)
|
||||
.organization(cloudFoundryProperties.getDefaultOrg())
|
||||
.organization(this.cloudFoundryProperties.getDefaultOrg())
|
||||
.build())
|
||||
.onErrorResume(e -> Mono.empty());
|
||||
.onErrorResume((e) -> Mono.empty());
|
||||
}
|
||||
|
||||
public Mono<Void> deleteDomain(String domain) {
|
||||
return cloudFoundryOperations
|
||||
.domains()
|
||||
return this.cloudFoundryOperations.domains()
|
||||
.list()
|
||||
.filter(d -> d.getName().equals(domain))
|
||||
.filter((d) -> d.getName().equals(domain))
|
||||
.map(Domain::getId)
|
||||
.flatMap(domainId -> cloudFoundryClient
|
||||
.privateDomains()
|
||||
.delete(DeletePrivateDomainRequest
|
||||
.builder()
|
||||
.privateDomainId(domainId)
|
||||
.build()))
|
||||
.flatMap((domainId) -> this.cloudFoundryClient.privateDomains()
|
||||
.delete(DeletePrivateDomainRequest.builder().privateDomainId(domainId).build()))
|
||||
.then();
|
||||
}
|
||||
|
||||
private Mono<AssociateOrganizationUserResponse> associateOrgUser(String orgId, String userId) {
|
||||
return cloudFoundryClient.organizations().associateUser(AssociateOrganizationUserRequest.builder()
|
||||
.organizationId(orgId)
|
||||
.userId(userId)
|
||||
.build());
|
||||
return this.cloudFoundryClient.organizations()
|
||||
.associateUser(AssociateOrganizationUserRequest.builder().organizationId(orgId).userId(userId).build());
|
||||
}
|
||||
|
||||
private Mono<AssociateOrganizationManagerResponse> associateOrgManager(String orgId, String userId) {
|
||||
return cloudFoundryClient.organizations().associateManager(AssociateOrganizationManagerRequest.builder()
|
||||
.organizationId(orgId)
|
||||
.managerId(userId)
|
||||
.build());
|
||||
return this.cloudFoundryClient.organizations()
|
||||
.associateManager(
|
||||
AssociateOrganizationManagerRequest.builder().organizationId(orgId).managerId(userId).build());
|
||||
}
|
||||
|
||||
private Mono<AssociateSpaceDeveloperResponse> associateSpaceDeveloper(String spaceId, String userId) {
|
||||
return cloudFoundryClient.spaces().associateDeveloper(AssociateSpaceDeveloperRequest.builder()
|
||||
.spaceId(spaceId)
|
||||
.developerId(userId)
|
||||
.build());
|
||||
return this.cloudFoundryClient.spaces()
|
||||
.associateDeveloper(AssociateSpaceDeveloperRequest.builder().spaceId(spaceId).developerId(userId).build());
|
||||
}
|
||||
|
||||
private Mono<Void> removeOrgUser(String orgId, String userId) {
|
||||
return cloudFoundryClient.organizations().removeUser(RemoveOrganizationUserRequest.builder()
|
||||
.organizationId(orgId)
|
||||
.userId(userId)
|
||||
.build());
|
||||
return this.cloudFoundryClient.organizations()
|
||||
.removeUser(RemoveOrganizationUserRequest.builder().organizationId(orgId).userId(userId).build());
|
||||
}
|
||||
|
||||
private Mono<Void> removeOrgManager(String orgId, String userId) {
|
||||
return cloudFoundryClient.organizations().removeManager(RemoveOrganizationManagerRequest.builder()
|
||||
.organizationId(orgId)
|
||||
.managerId(userId)
|
||||
.build());
|
||||
return this.cloudFoundryClient.organizations()
|
||||
.removeManager(RemoveOrganizationManagerRequest.builder().organizationId(orgId).managerId(userId).build());
|
||||
}
|
||||
|
||||
private Mono<Void> removeSpaceDeveloper(String spaceId, String userId) {
|
||||
return cloudFoundryClient.spaces().removeDeveloper(RemoveSpaceDeveloperRequest.builder()
|
||||
.spaceId(spaceId)
|
||||
.developerId(userId)
|
||||
.build());
|
||||
return this.cloudFoundryClient.spaces()
|
||||
.removeDeveloper(RemoveSpaceDeveloperRequest.builder().spaceId(spaceId).developerId(userId).build());
|
||||
}
|
||||
|
||||
private CloudFoundryOperations createOperationsForSpace(String space) {
|
||||
final String defaultOrg = cloudFoundryProperties.getDefaultOrg();
|
||||
final String defaultOrg = this.cloudFoundryProperties.getDefaultOrg();
|
||||
return DefaultCloudFoundryOperations.builder()
|
||||
.from((DefaultCloudFoundryOperations) cloudFoundryOperations)
|
||||
.from((DefaultCloudFoundryOperations) this.cloudFoundryOperations)
|
||||
.organization(defaultOrg)
|
||||
.space(space)
|
||||
.build();
|
||||
@@ -452,20 +411,18 @@ public class CloudFoundryService {
|
||||
private Map<String, String> appBrokerDeployerEnvironmentVariables(String brokerClientId) {
|
||||
Map<String, String> deployerVariables = new HashMap<>();
|
||||
deployerVariables.put(JBP_CONFIG_OPEN_JDK_JRE_ENV_VAR_NAME, JBP_CONFIG_OPEN_JDK_JRE_17);
|
||||
deployerVariables.put(DEPLOYER_PROPERTY_PREFIX + "api-host",
|
||||
cloudFoundryProperties.getApiHost());
|
||||
deployerVariables.put(DEPLOYER_PROPERTY_PREFIX + "api-host", this.cloudFoundryProperties.getApiHost());
|
||||
deployerVariables.put(DEPLOYER_PROPERTY_PREFIX + "api-port",
|
||||
String.valueOf(cloudFoundryProperties.getApiPort()));
|
||||
deployerVariables.put(DEPLOYER_PROPERTY_PREFIX + "default-org",
|
||||
cloudFoundryProperties.getDefaultOrg());
|
||||
String.valueOf(this.cloudFoundryProperties.getApiPort()));
|
||||
deployerVariables.put(DEPLOYER_PROPERTY_PREFIX + "default-org", this.cloudFoundryProperties.getDefaultOrg());
|
||||
deployerVariables.put(DEPLOYER_PROPERTY_PREFIX + "default-space",
|
||||
cloudFoundryProperties.getDefaultSpace());
|
||||
this.cloudFoundryProperties.getDefaultSpace());
|
||||
deployerVariables.put(DEPLOYER_PROPERTY_PREFIX + "skip-ssl-validation",
|
||||
String.valueOf(cloudFoundryProperties.isSkipSslValidation()));
|
||||
String.valueOf(this.cloudFoundryProperties.isSkipSslValidation()));
|
||||
deployerVariables.put(DEPLOYER_PROPERTY_PREFIX + "properties.memory", "1024M");
|
||||
deployerVariables.put(DEPLOYER_PROPERTY_PREFIX + "client-id", brokerClientId);
|
||||
deployerVariables.put(DEPLOYER_PROPERTY_PREFIX + "client-secret",
|
||||
CloudFoundryClientConfiguration.APP_BROKER_CLIENT_SECRET);
|
||||
CloudFoundryClientConfiguration.APP_BROKER_CLIENT_SECRET);
|
||||
return deployerVariables;
|
||||
}
|
||||
|
||||
@@ -478,7 +435,7 @@ public class CloudFoundryService {
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException(String.format("App Broker property '%s' is incorrectly formatted",
|
||||
Arrays.toString(propertyKeyValue)));
|
||||
Arrays.toString(propertyKeyValue)));
|
||||
}
|
||||
}
|
||||
return environment;
|
||||
|
||||
@@ -34,28 +34,27 @@ import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import static org.springframework.cloud.appbroker.acceptance.fixtures.cf.CloudFoundryClientConfiguration.USER_CLIENT_ID;
|
||||
import static org.springframework.cloud.appbroker.acceptance.fixtures.cf.CloudFoundryClientConfiguration.USER_CLIENT_SECRET;
|
||||
|
||||
@Service
|
||||
public final class UserCloudFoundryService {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(UserCloudFoundryService.class);
|
||||
|
||||
private final CloudFoundryOperations cloudFoundryOperations;
|
||||
|
||||
private final String targetOrg;
|
||||
|
||||
private final String targetSpace;
|
||||
|
||||
public UserCloudFoundryService(CloudFoundryOperations cloudFoundryOperations, CloudFoundryProperties cloudFoundryProperties) {
|
||||
DefaultCloudFoundryOperations sourceCloudFoundryOperations =
|
||||
(DefaultCloudFoundryOperations) cloudFoundryOperations;
|
||||
public UserCloudFoundryService(CloudFoundryOperations cloudFoundryOperations,
|
||||
CloudFoundryProperties cloudFoundryProperties) {
|
||||
DefaultCloudFoundryOperations sourceCloudFoundryOperations = (DefaultCloudFoundryOperations) cloudFoundryOperations;
|
||||
|
||||
this.targetOrg = cloudFoundryProperties.getDefaultOrg() + "-instances";
|
||||
this.targetSpace = cloudFoundryProperties.getDefaultSpace();
|
||||
|
||||
ClientCredentialsGrantTokenProvider tokenProvider = ClientCredentialsGrantTokenProvider.builder()
|
||||
.clientId(USER_CLIENT_ID)
|
||||
.clientSecret(USER_CLIENT_SECRET)
|
||||
.clientId(CloudFoundryClientConfiguration.USER_CLIENT_ID)
|
||||
.clientSecret(CloudFoundryClientConfiguration.USER_CLIENT_SECRET)
|
||||
.build();
|
||||
|
||||
ReactorCloudFoundryClient cloudFoundryClient = ReactorCloudFoundryClient.builder()
|
||||
@@ -63,11 +62,10 @@ public final class UserCloudFoundryService {
|
||||
.tokenProvider(tokenProvider)
|
||||
.build();
|
||||
|
||||
this.cloudFoundryOperations = DefaultCloudFoundryOperations
|
||||
.builder()
|
||||
this.cloudFoundryOperations = DefaultCloudFoundryOperations.builder()
|
||||
.from(sourceCloudFoundryOperations)
|
||||
.space(targetSpace)
|
||||
.organization(targetOrg)
|
||||
.space(this.targetSpace)
|
||||
.organization(this.targetOrg)
|
||||
.cloudFoundryClient(cloudFoundryClient)
|
||||
.build();
|
||||
}
|
||||
@@ -82,49 +80,45 @@ public final class UserCloudFoundryService {
|
||||
|
||||
public Mono<Void> deleteServiceInstance(String serviceInstanceName) {
|
||||
return getServiceInstance(serviceInstanceName)
|
||||
.flatMap(si -> cloudFoundryOperations.services().deleteInstance(DeleteServiceInstanceRequest.builder()
|
||||
.name(si.getName())
|
||||
.build())
|
||||
.doOnSuccess(v -> LOG.info("Success deleting service instance. serviceInstanceName={}",
|
||||
serviceInstanceName))
|
||||
.doOnError(error -> logError("deleting service instance", serviceInstanceName, error))
|
||||
.onErrorResume(e -> Mono.empty()))
|
||||
.doOnError(error -> logError("getting service instance", serviceInstanceName, error))
|
||||
.onErrorResume(e -> Mono.empty());
|
||||
.flatMap((si) -> this.cloudFoundryOperations.services()
|
||||
.deleteInstance(DeleteServiceInstanceRequest.builder().name(si.getName()).build())
|
||||
.doOnSuccess((v) -> LOG.info("Success deleting service instance. serviceInstanceName={}",
|
||||
serviceInstanceName))
|
||||
.doOnError((error) -> logError("deleting service instance", serviceInstanceName, error))
|
||||
.onErrorResume((e) -> Mono.empty()))
|
||||
.doOnError((error) -> logError("getting service instance", serviceInstanceName, error))
|
||||
.onErrorResume((e) -> Mono.empty());
|
||||
}
|
||||
|
||||
public Mono<Void> createServiceInstance(String planName,
|
||||
String serviceName,
|
||||
String serviceInstanceName,
|
||||
Map<String, Object> parameters) {
|
||||
return cloudFoundryOperations.services().createInstance(CreateServiceInstanceRequest.builder()
|
||||
.planName(planName)
|
||||
.serviceName(serviceName)
|
||||
.serviceInstanceName(serviceInstanceName)
|
||||
.parameters(parameters)
|
||||
.build())
|
||||
.doOnSuccess(item -> LOG.info("Success creating service instance. serviceInstanceName={}",
|
||||
serviceInstanceName))
|
||||
.doOnError(error -> logError("creating service instance", serviceInstanceName, error));
|
||||
public Mono<Void> createServiceInstance(String planName, String serviceName, String serviceInstanceName,
|
||||
Map<String, Object> parameters) {
|
||||
return this.cloudFoundryOperations.services()
|
||||
.createInstance(CreateServiceInstanceRequest.builder()
|
||||
.planName(planName)
|
||||
.serviceName(serviceName)
|
||||
.serviceInstanceName(serviceInstanceName)
|
||||
.parameters(parameters)
|
||||
.build())
|
||||
.doOnSuccess((item) -> LOG.info("Success creating service instance. serviceInstanceName={}",
|
||||
serviceInstanceName))
|
||||
.doOnError((error) -> logError("creating service instance", serviceInstanceName, error));
|
||||
}
|
||||
|
||||
public Mono<Void> updateServiceInstance(String serviceInstanceName, Map<String, Object> parameters) {
|
||||
return cloudFoundryOperations.services()
|
||||
return this.cloudFoundryOperations.services()
|
||||
.updateInstance(UpdateServiceInstanceRequest.builder()
|
||||
.serviceInstanceName(serviceInstanceName)
|
||||
.parameters(parameters)
|
||||
.build())
|
||||
.doOnSuccess(item -> LOG.info("Updated service instance " + serviceInstanceName))
|
||||
.doOnError(error -> logError("updating service instance", serviceInstanceName, error));
|
||||
.doOnSuccess((item) -> LOG.info("Updated service instance " + serviceInstanceName))
|
||||
.doOnError((error) -> logError("updating service instance", serviceInstanceName, error));
|
||||
}
|
||||
|
||||
public Mono<ServiceInstance> getServiceInstance(String serviceInstanceName) {
|
||||
return cloudFoundryOperations.services()
|
||||
.getInstance(GetServiceInstanceRequest.builder()
|
||||
.name(serviceInstanceName)
|
||||
.build())
|
||||
.doOnSuccess(item -> LOG.info("Got service instance " + serviceInstanceName))
|
||||
.doOnError(error -> logError("getting service instance", serviceInstanceName, error));
|
||||
return this.cloudFoundryOperations.services()
|
||||
.getInstance(GetServiceInstanceRequest.builder().name(serviceInstanceName).build())
|
||||
.doOnSuccess((item) -> LOG.info("Got service instance " + serviceInstanceName))
|
||||
.doOnError((error) -> logError("getting service instance", serviceInstanceName, error));
|
||||
}
|
||||
|
||||
private static void logError(String operation, String serviceInstanceName, Throwable error) {
|
||||
@@ -132,11 +126,12 @@ public final class UserCloudFoundryService {
|
||||
if (error instanceof UnknownCloudFoundryException) {
|
||||
UnknownCloudFoundryException unknownCloudFoundryException = (UnknownCloudFoundryException) error;
|
||||
logMessage = String.format("Error %s %s: %s %s", operation, serviceInstanceName,
|
||||
unknownCloudFoundryException.getMessage(), unknownCloudFoundryException.getPayload());
|
||||
unknownCloudFoundryException.getMessage(), unknownCloudFoundryException.getPayload());
|
||||
}
|
||||
else {
|
||||
logMessage = String.format("Error %s %s: %s", operation, serviceInstanceName, error);
|
||||
}
|
||||
LOG.error(logMessage, error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,45 +43,41 @@ public class UaaService {
|
||||
}
|
||||
|
||||
public Mono<GetClientResponse> getUaaClient(String clientId) {
|
||||
return uaaClient.clients().get(GetClientRequest
|
||||
.builder()
|
||||
.clientId(clientId)
|
||||
.build())
|
||||
.onErrorResume(e -> Mono.empty());
|
||||
return this.uaaClient.clients()
|
||||
.get(GetClientRequest.builder().clientId(clientId).build())
|
||||
.onErrorResume((e) -> Mono.empty());
|
||||
}
|
||||
|
||||
public Mono<Void> createClient(String clientId, String clientSecret, String... authorities) {
|
||||
final String clientNotFound = "CLIENT_NOT_FOUND";
|
||||
return getUaaClient(clientId)
|
||||
.defaultIfEmpty(GetClientResponse.builder()
|
||||
.clientId(clientNotFound)
|
||||
.authorities(clientNotFound)
|
||||
.build())
|
||||
.filter(response -> authoritiesChanged(response, authorities))
|
||||
.delayUntil(response -> {
|
||||
.defaultIfEmpty(GetClientResponse.builder().clientId(clientNotFound).authorities(clientNotFound).build())
|
||||
.filter((response) -> authoritiesChanged(response, authorities))
|
||||
.delayUntil((response) -> {
|
||||
if (!clientNotFound.equals(response.getClientId())) {
|
||||
return uaaClient.clients()
|
||||
return this.uaaClient.clients()
|
||||
.delete(DeleteClientRequest.builder().clientId(clientId).build())
|
||||
.doOnError(error -> LOG.error("Error deleting client: " + clientId + " with error: " + error));
|
||||
.doOnError(
|
||||
(error) -> LOG.error("Error deleting client: " + clientId + " with error: " + error));
|
||||
}
|
||||
return Mono.empty();
|
||||
})
|
||||
.flatMap(response -> uaaClient.clients()
|
||||
.create(CreateClientRequest
|
||||
.builder()
|
||||
.flatMap((response) -> this.uaaClient.clients()
|
||||
.create(CreateClientRequest.builder()
|
||||
.clientId(clientId)
|
||||
.clientSecret(clientSecret)
|
||||
.authorizedGrantType(GrantType.CLIENT_CREDENTIALS)
|
||||
.authorities(authorities)
|
||||
.build())
|
||||
.onErrorResume(e -> e.getMessage().contains("Client already exists: " + clientId), e -> Mono.empty())
|
||||
.doOnError(error -> LOG.error("Error creating client: " + clientId + " with error: " + error)))
|
||||
.onErrorResume((e) -> e.getMessage().contains("Client already exists: " + clientId),
|
||||
(e) -> Mono.empty())
|
||||
.doOnError((error) -> LOG.error("Error creating client: " + clientId + " with error: " + error)))
|
||||
.then();
|
||||
}
|
||||
|
||||
private boolean authoritiesChanged(GetClientResponse response, String... authorities) {
|
||||
return !response.getAuthorities().containsAll(Arrays.asList(authorities)) ||
|
||||
response.getAuthorities().size() != authorities.length;
|
||||
return !response.getAuthorities().containsAll(Arrays.asList(authorities))
|
||||
|| response.getAuthorities().size() != authorities.length;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
|
||||
@@ -71,7 +71,11 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* App Broker Auto-configuration
|
||||
* App Broker Auto-configuration.
|
||||
*
|
||||
* @author Scott Frederick
|
||||
* @author Roy Clarkson
|
||||
* @author Alberto Rios
|
||||
*/
|
||||
@Configuration
|
||||
@AutoConfigureAfter(CloudFoundryAppDeployerAutoConfiguration.class)
|
||||
@@ -83,8 +87,7 @@ public class AppBrokerAutoConfiguration {
|
||||
private static final String PROPERTY_PREFIX = "spring.cloud.appbroker";
|
||||
|
||||
/**
|
||||
* Provide a {@link DeployerClient} bean
|
||||
*
|
||||
* Provide a {@link DeployerClient} bean.
|
||||
* @param appDeployer the AppDeployer bean
|
||||
* @return the bean
|
||||
*/
|
||||
@@ -94,8 +97,7 @@ public class AppBrokerAutoConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link BackingAppDeploymentService} bean
|
||||
*
|
||||
* Provide a {@link BackingAppDeploymentService} bean.
|
||||
* @param deployerClient the DeployerClient bean
|
||||
* @return the bean
|
||||
*/
|
||||
@@ -106,8 +108,7 @@ public class AppBrokerAutoConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link ManagementClient} bean
|
||||
*
|
||||
* Provide a {@link ManagementClient} bean.
|
||||
* @param appManager the AppManager bean
|
||||
* @return the bean
|
||||
*/
|
||||
@@ -117,8 +118,7 @@ public class AppBrokerAutoConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link BackingAppManagementService} bean
|
||||
*
|
||||
* Provide a {@link BackingAppManagementService} bean.
|
||||
* @param managementClient the ManagementClient bean
|
||||
* @param appDeployer the AppDeployer bean
|
||||
* @param brokeredServices the BrokeredServices bean
|
||||
@@ -127,13 +127,12 @@ public class AppBrokerAutoConfiguration {
|
||||
*/
|
||||
@Bean
|
||||
public BackingAppManagementService backingAppManagementService(ManagementClient managementClient,
|
||||
AppDeployer appDeployer, BrokeredServices brokeredServices, TargetService targetService) {
|
||||
AppDeployer appDeployer, BrokeredServices brokeredServices, TargetService targetService) {
|
||||
return new BackingAppManagementService(managementClient, appDeployer, brokeredServices, targetService);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link BrokeredServices} bean
|
||||
*
|
||||
* Provide a {@link BrokeredServices} bean.
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
@@ -144,38 +143,35 @@ public class AppBrokerAutoConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link ServiceInstanceStateRepository} bean
|
||||
*
|
||||
* Provide a {@link ServiceInstanceStateRepository} bean.
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(ServiceInstanceStateRepository.class)
|
||||
public ServiceInstanceStateRepository serviceInstanceStateRepository() {
|
||||
if (LOG.isWarnEnabled()) {
|
||||
LOG.warn("The InMemoryServiceInstanceStateRepository is provided for demonstration and testing purposes " +
|
||||
"only. It is not suitable for production applications!");
|
||||
LOG.warn("The InMemoryServiceInstanceStateRepository is provided for demonstration and testing purposes "
|
||||
+ "only. It is not suitable for production applications!");
|
||||
}
|
||||
return new InMemoryServiceInstanceStateRepository();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link ServiceInstanceBindingStateRepository} bean
|
||||
*
|
||||
* Provide a {@link ServiceInstanceBindingStateRepository} bean.
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(ServiceInstanceBindingStateRepository.class)
|
||||
public ServiceInstanceBindingStateRepository serviceInstanceBindingStateRepository() {
|
||||
if (LOG.isWarnEnabled()) {
|
||||
LOG.warn("The InMemoryServiceInstanceBindingStateRepository is provided for demonstration and testing " +
|
||||
"purposes only. It is not suitable for production applications!");
|
||||
LOG.warn("The InMemoryServiceInstanceBindingStateRepository is provided for demonstration and testing "
|
||||
+ "purposes only. It is not suitable for production applications!");
|
||||
}
|
||||
return new InMemoryServiceInstanceBindingStateRepository();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide an {@link EnvironmentMappingParametersTransformerFactory} bean
|
||||
*
|
||||
* Provide an {@link EnvironmentMappingParametersTransformerFactory} bean.
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
@@ -184,8 +180,7 @@ public class AppBrokerAutoConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link ParameterMappingParametersTransformerFactory} bean
|
||||
*
|
||||
* Provide a {@link ParameterMappingParametersTransformerFactory} bean.
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
@@ -194,8 +189,7 @@ public class AppBrokerAutoConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link ParameterMappingParametersTransformerFactory} bean
|
||||
*
|
||||
* Provide a {@link ParameterMappingParametersTransformerFactory} bean.
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
@@ -204,32 +198,29 @@ public class AppBrokerAutoConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link BackingApplicationsParametersTransformationService} bean
|
||||
*
|
||||
* Provide a {@link BackingApplicationsParametersTransformationService} bean.
|
||||
* @param transformers a collection of parameter transformers
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
public BackingApplicationsParametersTransformationService backingApplicationsParametersTransformationService(
|
||||
List<ParametersTransformerFactory<BackingApplication, ?>> transformers) {
|
||||
List<ParametersTransformerFactory<BackingApplication, ?>> transformers) {
|
||||
return new BackingApplicationsParametersTransformationService(transformers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link BackingServicesParametersTransformationService} bean
|
||||
*
|
||||
* Provide a {@link BackingServicesParametersTransformationService} bean.
|
||||
* @param transformers a collection of parameter transformers
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
public BackingServicesParametersTransformationService backingServicesParametersTransformationService(
|
||||
List<ParametersTransformerFactory<BackingService, ?>> transformers) {
|
||||
List<ParametersTransformerFactory<BackingService, ?>> transformers) {
|
||||
return new BackingServicesParametersTransformationService(transformers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link SpacePerServiceInstance} bean
|
||||
*
|
||||
* Provide a {@link SpacePerServiceInstance} bean.
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
@@ -238,8 +229,7 @@ public class AppBrokerAutoConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link ServiceInstanceGuidSuffix} bean
|
||||
*
|
||||
* Provide a {@link ServiceInstanceGuidSuffix} bean.
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
@@ -248,8 +238,7 @@ public class AppBrokerAutoConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link TargetService} bean
|
||||
*
|
||||
* Provide a {@link TargetService} bean.
|
||||
* @param targets a collection of targets
|
||||
* @return the bean
|
||||
*/
|
||||
@@ -259,8 +248,7 @@ public class AppBrokerAutoConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link BackingServicesProvisionService} bean
|
||||
*
|
||||
* Provide a {@link BackingServicesProvisionService} bean.
|
||||
* @param deployerClient the DeployerClient bean
|
||||
* @return the bean
|
||||
*/
|
||||
@@ -271,8 +259,7 @@ public class AppBrokerAutoConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link BackingSpaceManagementService} bean
|
||||
*
|
||||
* Provide a {@link BackingSpaceManagementService} bean.
|
||||
* @param deployerClient the DeployerClient bean
|
||||
* @return the bean
|
||||
*/
|
||||
@@ -283,94 +270,79 @@ public class AppBrokerAutoConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link CreateServiceInstanceWorkflow} bean
|
||||
*
|
||||
* Provide a {@link CreateServiceInstanceWorkflow} bean.
|
||||
* @param brokeredServices the BrokeredServices bean
|
||||
* @param backingAppDeploymentService the BackingAppDeploymentService bean
|
||||
* @param appsParametersTransformationService the BackingApplicationsParametersTransformationService bean
|
||||
* @param servicesParametersTransformationService the BackingServicesParametersTransformationService bean
|
||||
* @param appsParametersTransformationService the
|
||||
* BackingApplicationsParametersTransformationService bean
|
||||
* @param servicesParametersTransformationService the
|
||||
* BackingServicesParametersTransformationService bean
|
||||
* @param targetService the TargetService bean
|
||||
* @param backingServicesProvisionService the BackingServicesProvisionService bean
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
public CreateServiceInstanceWorkflow appDeploymentCreateServiceInstanceWorkflow(
|
||||
BrokeredServices brokeredServices, BackingAppDeploymentService backingAppDeploymentService,
|
||||
BackingApplicationsParametersTransformationService appsParametersTransformationService,
|
||||
BackingServicesParametersTransformationService servicesParametersTransformationService,
|
||||
TargetService targetService, BackingServicesProvisionService backingServicesProvisionService) {
|
||||
return new AppDeploymentCreateServiceInstanceWorkflow(
|
||||
brokeredServices,
|
||||
backingAppDeploymentService,
|
||||
backingServicesProvisionService,
|
||||
appsParametersTransformationService,
|
||||
servicesParametersTransformationService,
|
||||
targetService);
|
||||
public CreateServiceInstanceWorkflow appDeploymentCreateServiceInstanceWorkflow(BrokeredServices brokeredServices,
|
||||
BackingAppDeploymentService backingAppDeploymentService,
|
||||
BackingApplicationsParametersTransformationService appsParametersTransformationService,
|
||||
BackingServicesParametersTransformationService servicesParametersTransformationService,
|
||||
TargetService targetService, BackingServicesProvisionService backingServicesProvisionService) {
|
||||
return new AppDeploymentCreateServiceInstanceWorkflow(brokeredServices, backingAppDeploymentService,
|
||||
backingServicesProvisionService, appsParametersTransformationService,
|
||||
servicesParametersTransformationService, targetService);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link UpdateServiceInstanceWorkflow} bean
|
||||
*
|
||||
* Provide a {@link UpdateServiceInstanceWorkflow} bean.
|
||||
* @param brokeredServices the BrokeredServices bean
|
||||
* @param backingAppDeploymentService the BackingAppDeploymentService bean
|
||||
* @param backingAppManagementService the BackingAppManagementService bean
|
||||
* @param backingServicesProvisionService the BackingServicesProvisionService bean
|
||||
* @param appsParametersTransformationService the BackingApplicationsParametersTransformationService bean
|
||||
* @param servicesParametersTransformationService the BackingServicesParametersTransformationService bean
|
||||
* @param appsParametersTransformationService the
|
||||
* BackingApplicationsParametersTransformationService bean
|
||||
* @param servicesParametersTransformationService the
|
||||
* BackingServicesParametersTransformationService bean
|
||||
* @param targetService the TargetService bean
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
public UpdateServiceInstanceWorkflow appDeploymentUpdateServiceInstanceWorkflow(
|
||||
BrokeredServices brokeredServices,
|
||||
BackingAppDeploymentService backingAppDeploymentService,
|
||||
BackingAppManagementService backingAppManagementService,
|
||||
BackingServicesProvisionService backingServicesProvisionService,
|
||||
BackingApplicationsParametersTransformationService appsParametersTransformationService,
|
||||
BackingServicesParametersTransformationService servicesParametersTransformationService,
|
||||
TargetService targetService) {
|
||||
public UpdateServiceInstanceWorkflow appDeploymentUpdateServiceInstanceWorkflow(BrokeredServices brokeredServices,
|
||||
BackingAppDeploymentService backingAppDeploymentService,
|
||||
BackingAppManagementService backingAppManagementService,
|
||||
BackingServicesProvisionService backingServicesProvisionService,
|
||||
BackingApplicationsParametersTransformationService appsParametersTransformationService,
|
||||
BackingServicesParametersTransformationService servicesParametersTransformationService,
|
||||
TargetService targetService) {
|
||||
|
||||
return new AppDeploymentUpdateServiceInstanceWorkflow(
|
||||
brokeredServices,
|
||||
backingAppDeploymentService,
|
||||
backingAppManagementService,
|
||||
backingServicesProvisionService,
|
||||
appsParametersTransformationService,
|
||||
servicesParametersTransformationService,
|
||||
targetService);
|
||||
return new AppDeploymentUpdateServiceInstanceWorkflow(brokeredServices, backingAppDeploymentService,
|
||||
backingAppManagementService, backingServicesProvisionService, appsParametersTransformationService,
|
||||
servicesParametersTransformationService, targetService);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link DeleteServiceInstanceWorkflow} bean
|
||||
*
|
||||
* Provide a {@link DeleteServiceInstanceWorkflow} bean.
|
||||
* @param brokeredServices the BrokeredServices bean
|
||||
* @param backingAppDeploymentService the BackingAppDeploymentService bean
|
||||
* @param backingAppManagementService the BackingAppManagementService bean
|
||||
* @param backingServicesProvisionService the BackingServicesProvisionService bean
|
||||
* @param backingSpaceManagementService the BackingSpaceManagementService bean
|
||||
* @param targetService the TargetService bean
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
public DeleteServiceInstanceWorkflow appDeploymentDeleteServiceInstanceWorkflow(
|
||||
BrokeredServices brokeredServices, BackingAppDeploymentService backingAppDeploymentService,
|
||||
BackingAppManagementService backingAppManagementService,
|
||||
BackingServicesProvisionService backingServicesProvisionService,
|
||||
BackingSpaceManagementService backingSpaceManagementService,
|
||||
TargetService targetService) {
|
||||
public DeleteServiceInstanceWorkflow appDeploymentDeleteServiceInstanceWorkflow(BrokeredServices brokeredServices,
|
||||
BackingAppDeploymentService backingAppDeploymentService,
|
||||
BackingAppManagementService backingAppManagementService,
|
||||
BackingServicesProvisionService backingServicesProvisionService,
|
||||
BackingSpaceManagementService backingSpaceManagementService, TargetService targetService) {
|
||||
|
||||
return new AppDeploymentDeleteServiceInstanceWorkflow(
|
||||
brokeredServices,
|
||||
backingAppDeploymentService,
|
||||
backingAppManagementService,
|
||||
backingServicesProvisionService,
|
||||
backingSpaceManagementService,
|
||||
targetService
|
||||
);
|
||||
return new AppDeploymentDeleteServiceInstanceWorkflow(brokeredServices, backingAppDeploymentService,
|
||||
backingAppManagementService, backingServicesProvisionService, backingSpaceManagementService,
|
||||
targetService);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link WorkflowServiceInstanceService} bean
|
||||
*
|
||||
* Provide a {@link WorkflowServiceInstanceService} bean.
|
||||
* @param stateRepository the ServiceInstanceStateRepository bean
|
||||
* @param createWorkflows a collection of create workflows
|
||||
* @param deleteWorkflows a collection of delete workflows
|
||||
@@ -380,30 +352,33 @@ public class AppBrokerAutoConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(ServiceInstanceService.class)
|
||||
public WorkflowServiceInstanceService serviceInstanceService(ServiceInstanceStateRepository stateRepository,
|
||||
List<CreateServiceInstanceWorkflow> createWorkflows, List<DeleteServiceInstanceWorkflow> deleteWorkflows,
|
||||
List<UpdateServiceInstanceWorkflow> updateWorkflows) {
|
||||
List<CreateServiceInstanceWorkflow> createWorkflows, List<DeleteServiceInstanceWorkflow> deleteWorkflows,
|
||||
List<UpdateServiceInstanceWorkflow> updateWorkflows) {
|
||||
return new WorkflowServiceInstanceService(stateRepository, createWorkflows, deleteWorkflows, updateWorkflows);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link WorkflowServiceInstanceBindingService} bean
|
||||
*
|
||||
* Provide a {@link WorkflowServiceInstanceBindingService} bean.
|
||||
* @param stateRepository the ServiceInstanceBindingStateRepository bean
|
||||
* @param createServiceInstanceAppBindingWorkflows a collection of create app binding workflows
|
||||
* @param createServiceInstanceRouteBindingWorkflows a collection of create route binding workflows
|
||||
* @param createServiceInstanceAppBindingWorkflows a collection of create app binding
|
||||
* workflows
|
||||
* @param createServiceInstanceRouteBindingWorkflows a collection of create route
|
||||
* binding workflows
|
||||
* @param deleteServiceInstanceBindingWorkflows a collection of update workflows
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(ServiceInstanceBindingService.class)
|
||||
public WorkflowServiceInstanceBindingService serviceInstanceBindingService(
|
||||
ServiceInstanceBindingStateRepository stateRepository,
|
||||
@Autowired(required = false) List<CreateServiceInstanceAppBindingWorkflow> createServiceInstanceAppBindingWorkflows,
|
||||
@Autowired(required = false) List<CreateServiceInstanceRouteBindingWorkflow> createServiceInstanceRouteBindingWorkflows,
|
||||
@Autowired(required = false) List<DeleteServiceInstanceBindingWorkflow> deleteServiceInstanceBindingWorkflows) {
|
||||
return new WorkflowServiceInstanceBindingService(stateRepository,
|
||||
createServiceInstanceAppBindingWorkflows, createServiceInstanceRouteBindingWorkflows,
|
||||
deleteServiceInstanceBindingWorkflows);
|
||||
ServiceInstanceBindingStateRepository stateRepository,
|
||||
@Autowired(
|
||||
required = false) List<CreateServiceInstanceAppBindingWorkflow> createServiceInstanceAppBindingWorkflows,
|
||||
@Autowired(
|
||||
required = false) List<CreateServiceInstanceRouteBindingWorkflow> createServiceInstanceRouteBindingWorkflows,
|
||||
@Autowired(
|
||||
required = false) List<DeleteServiceInstanceBindingWorkflow> deleteServiceInstanceBindingWorkflows) {
|
||||
return new WorkflowServiceInstanceBindingService(stateRepository, createServiceInstanceAppBindingWorkflows,
|
||||
createServiceInstanceRouteBindingWorkflows, deleteServiceInstanceBindingWorkflows);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -58,7 +58,11 @@ import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Auto-configuration support for deploying apps to Cloud Foundry
|
||||
* Auto-configuration support for deploying apps to Cloud Foundry.
|
||||
*
|
||||
* @author Roy Clarkson
|
||||
* @author Scott Frederick
|
||||
* @author Alberto Rios
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnProperty(CloudFoundryAppDeployerAutoConfiguration.PROPERTY_PREFIX + ".api-host")
|
||||
@@ -68,8 +72,7 @@ public class CloudFoundryAppDeployerAutoConfiguration {
|
||||
protected static final String PROPERTY_PREFIX = "spring.cloud.appbroker.deployer.cloudfoundry";
|
||||
|
||||
/**
|
||||
* Provide a {@link CloudFoundryDeploymentProperties} bean
|
||||
*
|
||||
* Provide a {@link CloudFoundryDeploymentProperties} bean.
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
@@ -79,8 +82,7 @@ public class CloudFoundryAppDeployerAutoConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link CloudFoundryTargetProperties} bean
|
||||
*
|
||||
* Provide a {@link CloudFoundryTargetProperties} bean.
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
@@ -90,8 +92,7 @@ public class CloudFoundryAppDeployerAutoConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link AppDeployer} bean
|
||||
*
|
||||
* Provide a {@link AppDeployer} bean.
|
||||
* @param deploymentProperties the CloudFoundryDeploymentProperties bean
|
||||
* @param cloudFoundryOperations the CloudFoundryOperations bean
|
||||
* @param cloudFoundryClient the CloudFoundryClient bean
|
||||
@@ -102,16 +103,15 @@ public class CloudFoundryAppDeployerAutoConfiguration {
|
||||
*/
|
||||
@Bean
|
||||
public AppDeployer cloudFoundryAppDeployer(CloudFoundryDeploymentProperties deploymentProperties,
|
||||
CloudFoundryOperations cloudFoundryOperations, CloudFoundryClient cloudFoundryClient,
|
||||
CloudFoundryOperationsUtils operationsUtils, CloudFoundryTargetProperties targetProperties,
|
||||
ResourceLoader resourceLoader) {
|
||||
CloudFoundryOperations cloudFoundryOperations, CloudFoundryClient cloudFoundryClient,
|
||||
CloudFoundryOperationsUtils operationsUtils, CloudFoundryTargetProperties targetProperties,
|
||||
ResourceLoader resourceLoader) {
|
||||
return new CloudFoundryAppDeployer(deploymentProperties, cloudFoundryOperations, cloudFoundryClient,
|
||||
operationsUtils, targetProperties, resourceLoader);
|
||||
operationsUtils, targetProperties, resourceLoader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide an {@link AppManager} bean
|
||||
*
|
||||
* Provide an {@link AppManager} bean.
|
||||
* @param cloudFoundryOperationsUtils the CloudFoundryOperationsUtils bean
|
||||
* @return the bean
|
||||
*/
|
||||
@@ -121,8 +121,7 @@ public class CloudFoundryAppDeployerAutoConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide an {@link OAuth2Client} bean
|
||||
*
|
||||
* Provide an {@link OAuth2Client} bean.
|
||||
* @param uaaClient the UaaClient bean
|
||||
* @return the bean
|
||||
*/
|
||||
@@ -132,15 +131,14 @@ public class CloudFoundryAppDeployerAutoConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link ReactorCloudFoundryClient} bean
|
||||
*
|
||||
* Provide a {@link ReactorCloudFoundryClient} bean.
|
||||
* @param connectionContext the ConnectionContext bean
|
||||
* @param tokenProvider the TokenProvider bean
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
public ReactorCloudFoundryClient cloudFoundryClient(@ConnectionContextQualifier ConnectionContext connectionContext,
|
||||
@TokenQualifier TokenProvider tokenProvider) {
|
||||
@TokenQualifier TokenProvider tokenProvider) {
|
||||
return ReactorCloudFoundryClient.builder()
|
||||
.connectionContext(connectionContext)
|
||||
.tokenProvider(tokenProvider)
|
||||
@@ -148,8 +146,7 @@ public class CloudFoundryAppDeployerAutoConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link CloudFoundryOperations} bean
|
||||
*
|
||||
* Provide a {@link CloudFoundryOperations} bean.
|
||||
* @param properties the CloudFoundryTargetProperties bean
|
||||
* @param client the CloudFoundryClient bean
|
||||
* @param dopplerClient the DopplerClient bean
|
||||
@@ -158,7 +155,7 @@ public class CloudFoundryAppDeployerAutoConfiguration {
|
||||
*/
|
||||
@Bean
|
||||
public CloudFoundryOperations cloudFoundryOperations(CloudFoundryTargetProperties properties,
|
||||
CloudFoundryClient client, DopplerClient dopplerClient, @UaaClientQualifier UaaClient uaaClient) {
|
||||
CloudFoundryClient client, DopplerClient dopplerClient, @UaaClientQualifier UaaClient uaaClient) {
|
||||
return DefaultCloudFoundryOperations.builder()
|
||||
.cloudFoundryClient(client)
|
||||
.dopplerClient(dopplerClient)
|
||||
@@ -169,8 +166,7 @@ public class CloudFoundryAppDeployerAutoConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link CloudFoundryOperationsUtils} bean
|
||||
*
|
||||
* Provide a {@link CloudFoundryOperationsUtils} bean.
|
||||
* @param operations the CloudFoundryOperations bean
|
||||
* @return the bean
|
||||
*/
|
||||
@@ -180,8 +176,7 @@ public class CloudFoundryAppDeployerAutoConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link DefaultConnectionContext} bean
|
||||
*
|
||||
* Provide a {@link DefaultConnectionContext} bean.
|
||||
* @param properties the CloudFoundryTargetProperties bean
|
||||
* @return the bean
|
||||
*/
|
||||
@@ -197,31 +192,26 @@ public class CloudFoundryAppDeployerAutoConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link ReactorDopplerClient} bean
|
||||
*
|
||||
* Provide a {@link ReactorDopplerClient} bean.
|
||||
* @param connectionContext the ConnectionContext bean
|
||||
* @param tokenProvider the TokenProvider bean
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
public ReactorDopplerClient dopplerClient(@ConnectionContextQualifier ConnectionContext connectionContext,
|
||||
@TokenQualifier TokenProvider tokenProvider) {
|
||||
return ReactorDopplerClient.builder()
|
||||
.connectionContext(connectionContext)
|
||||
.tokenProvider(tokenProvider)
|
||||
.build();
|
||||
@TokenQualifier TokenProvider tokenProvider) {
|
||||
return ReactorDopplerClient.builder().connectionContext(connectionContext).tokenProvider(tokenProvider).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link LogCacheClient} bean
|
||||
*
|
||||
* Provide a {@link LogCacheClient} bean.
|
||||
* @param connectionContext the ConnectionContext bean
|
||||
* @param tokenProvider the TokenProvider bean
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
public LogCacheClient logCacheClient(@ConnectionContextQualifier ConnectionContext connectionContext,
|
||||
@TokenQualifier TokenProvider tokenProvider) {
|
||||
@TokenQualifier TokenProvider tokenProvider) {
|
||||
return ReactorLogCacheClient.builder()
|
||||
.connectionContext(connectionContext)
|
||||
.tokenProvider(tokenProvider)
|
||||
@@ -229,8 +219,7 @@ public class CloudFoundryAppDeployerAutoConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link TokenProvider} bean
|
||||
*
|
||||
* Provide a {@link TokenProvider} bean.
|
||||
* @param properties the CloudFoundryTargetProperties bean
|
||||
* @return the bean
|
||||
*/
|
||||
@@ -242,9 +231,8 @@ public class CloudFoundryAppDeployerAutoConfiguration {
|
||||
boolean isUsernameAndPasswordSet = Stream.of(properties.getUsername(), properties.getPassword())
|
||||
.allMatch(StringUtils::hasText);
|
||||
if (isClientIdAndSecretSet && isUsernameAndPasswordSet) {
|
||||
throw new IllegalStateException(
|
||||
String.format("(%1$s.client_id / %1$s.client_secret) must not be set when\n" +
|
||||
"(%1$s.username / %1$s.password) are also set", PROPERTY_PREFIX));
|
||||
throw new IllegalStateException(String.format("(%1$s.client_id / %1$s.client_secret) must not be set when\n"
|
||||
+ "(%1$s.username / %1$s.password) are also set", PROPERTY_PREFIX));
|
||||
}
|
||||
else if (isClientIdAndSecretSet) {
|
||||
return ClientCredentialsGrantTokenProvider.builder()
|
||||
@@ -260,15 +248,13 @@ public class CloudFoundryAppDeployerAutoConfiguration {
|
||||
.build();
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException(
|
||||
String.format("Either (%1$s.client_id and %1$s.client_secret) or\n" +
|
||||
"(%1$s.username and %1$s.password) properties must be set", PROPERTY_PREFIX));
|
||||
throw new IllegalStateException(String.format("Either (%1$s.client_id and %1$s.client_secret) or\n"
|
||||
+ "(%1$s.username and %1$s.password) properties must be set", PROPERTY_PREFIX));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a {@link ReactorUaaClient} bean
|
||||
*
|
||||
* Provide a {@link ReactorUaaClient} bean.
|
||||
* @param connectionContext the ConnectionContext bean
|
||||
* @param tokenProvider the TokenProvider bean
|
||||
* @return the bean
|
||||
@@ -276,15 +262,12 @@ public class CloudFoundryAppDeployerAutoConfiguration {
|
||||
@UaaClientQualifier
|
||||
@Bean
|
||||
public ReactorUaaClient uaaClient(@ConnectionContextQualifier ConnectionContext connectionContext,
|
||||
@TokenQualifier TokenProvider tokenProvider) {
|
||||
return ReactorUaaClient.builder()
|
||||
.connectionContext(connectionContext)
|
||||
.tokenProvider(tokenProvider)
|
||||
.build();
|
||||
@TokenQualifier TokenProvider tokenProvider) {
|
||||
return ReactorUaaClient.builder().connectionContext(connectionContext).tokenProvider(tokenProvider).build();
|
||||
}
|
||||
|
||||
@Qualifier
|
||||
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD, ElementType.TYPE})
|
||||
@Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD, ElementType.TYPE })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface TokenQualifier {
|
||||
|
||||
@@ -293,7 +276,7 @@ public class CloudFoundryAppDeployerAutoConfiguration {
|
||||
}
|
||||
|
||||
@Qualifier
|
||||
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD, ElementType.TYPE})
|
||||
@Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD, ElementType.TYPE })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface UaaClientQualifier {
|
||||
|
||||
@@ -302,7 +285,7 @@ public class CloudFoundryAppDeployerAutoConfiguration {
|
||||
}
|
||||
|
||||
@Qualifier
|
||||
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD, ElementType.TYPE})
|
||||
@Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD, ElementType.TYPE })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ConnectionContextQualifier {
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2016-2024 the original author or authors
|
||||
* Copyright 2002-2024 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -45,7 +45,7 @@ public class ServiceInstanceLogStreamAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
public StreamingLogWebSocketHandler streamingLogWebSocketHandler(
|
||||
ApplicationEventPublisher applicationEventPublisher) {
|
||||
ApplicationEventPublisher applicationEventPublisher) {
|
||||
return new StreamingLogWebSocketHandler(applicationEventPublisher);
|
||||
}
|
||||
|
||||
@@ -69,15 +69,15 @@ public class ServiceInstanceLogStreamAutoConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public LogStreamPublisher<org.cloudfoundry.dropsonde.events.Envelope> streamLogsPublisher(
|
||||
CloudFoundryClient cloudFoundryClient,
|
||||
LogCacheClient logCacheClient,
|
||||
ApplicationIdsProvider applicationIdsProvider) {
|
||||
CloudFoundryClient cloudFoundryClient, LogCacheClient logCacheClient,
|
||||
ApplicationIdsProvider applicationIdsProvider) {
|
||||
return new LogCacheStreamPublisher(cloudFoundryClient, logCacheClient, applicationIdsProvider);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ApplicationLogStreamPublisher applicationLogsPublisher(LogStreamPublisher<org.cloudfoundry.dropsonde.events.Envelope> logStreamPublisher,
|
||||
ApplicationEventPublisher eventPublisher) {
|
||||
public ApplicationLogStreamPublisher applicationLogsPublisher(
|
||||
LogStreamPublisher<org.cloudfoundry.dropsonde.events.Envelope> logStreamPublisher,
|
||||
ApplicationEventPublisher eventPublisher) {
|
||||
return new ApplicationLogStreamPublisher(logStreamPublisher, eventPublisher);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2016-2024 the original author or authors
|
||||
* Copyright 2002-2024 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -34,9 +34,8 @@ import org.springframework.context.annotation.Configuration;
|
||||
public class ServiceInstanceRecentLogsAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
public RecentLogsProvider recentLogsProvider(
|
||||
LogCacheClient logCacheClient,
|
||||
ApplicationIdsProvider applicationIdsProvider) {
|
||||
public RecentLogsProvider recentLogsProvider(LogCacheClient logCacheClient,
|
||||
ApplicationIdsProvider applicationIdsProvider) {
|
||||
return new ApplicationRecentLogsProvider(logCacheClient, applicationIdsProvider);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016-2024 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* App Broker Auto-Configuration.
|
||||
*/
|
||||
package org.springframework.cloud.appbroker.autoconfigure;
|
||||
@@ -63,73 +63,61 @@ import org.springframework.context.annotation.Configuration;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
class AppBrokerAutoConfigurationTest {
|
||||
class AppBrokerAutoConfigurationTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(
|
||||
CloudFoundryAppDeployerAutoConfiguration.class,
|
||||
AppBrokerAutoConfiguration.class
|
||||
));
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner().withConfiguration(
|
||||
AutoConfigurations.of(CloudFoundryAppDeployerAutoConfiguration.class, AppBrokerAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
void servicesAreCreatedWithCloudFoundryConfigured() {
|
||||
configuredContext()
|
||||
.run(context -> {
|
||||
assertBeansCreated(context);
|
||||
assertPropertiesLoaded(context);
|
||||
configuredContext().run((context) -> {
|
||||
assertBeansCreated(context);
|
||||
assertPropertiesLoaded(context);
|
||||
|
||||
assertThat(context)
|
||||
.hasSingleBean(ServiceInstanceBindingService.class)
|
||||
.getBean(ServiceInstanceBindingService.class)
|
||||
.isExactlyInstanceOf(WorkflowServiceInstanceBindingService.class);
|
||||
});
|
||||
assertThat(context).hasSingleBean(ServiceInstanceBindingService.class)
|
||||
.getBean(ServiceInstanceBindingService.class)
|
||||
.isExactlyInstanceOf(WorkflowServiceInstanceBindingService.class);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void servicesAreNotCreatedWithoutDeployerConfiguration() {
|
||||
this.contextRunner
|
||||
.run((context) -> {
|
||||
assertThat(context).doesNotHaveBean(BackingApplications.class);
|
||||
assertThat(context).doesNotHaveBean(DeployerClient.class);
|
||||
});
|
||||
this.contextRunner.run((context) -> {
|
||||
assertThat(context).doesNotHaveBean(BackingApplications.class);
|
||||
assertThat(context).doesNotHaveBean(DeployerClient.class);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void bindingServiceIsNotCreatedIfProvided() {
|
||||
configuredContext()
|
||||
.withUserConfiguration(CustomBindingServiceConfiguration.class)
|
||||
.run(context -> {
|
||||
assertBeansCreated(context);
|
||||
configuredContext().withUserConfiguration(CustomBindingServiceConfiguration.class).run((context) -> {
|
||||
assertBeansCreated(context);
|
||||
|
||||
assertThat(context)
|
||||
.hasSingleBean(ServiceInstanceBindingService.class)
|
||||
.getBean(ServiceInstanceBindingService.class)
|
||||
.isExactlyInstanceOf(TestServiceInstanceBindingService.class);
|
||||
});
|
||||
assertThat(context).hasSingleBean(ServiceInstanceBindingService.class)
|
||||
.getBean(ServiceInstanceBindingService.class)
|
||||
.isExactlyInstanceOf(TestServiceInstanceBindingService.class);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void serviceInstanceIsNotCreatedIfProvided() {
|
||||
configuredContext()
|
||||
.withUserConfiguration(CustomServiceConfiguration.class)
|
||||
.run(context -> {
|
||||
assertBeansCreated(context);
|
||||
configuredContext().withUserConfiguration(CustomServiceConfiguration.class).run((context) -> {
|
||||
assertBeansCreated(context);
|
||||
|
||||
assertThat(context)
|
||||
.hasSingleBean(ServiceInstanceService.class)
|
||||
.getBean(ServiceInstanceService.class)
|
||||
.isExactlyInstanceOf(TestServiceInstanceService.class);
|
||||
});
|
||||
assertThat(context).hasSingleBean(ServiceInstanceService.class)
|
||||
.getBean(ServiceInstanceService.class)
|
||||
.isExactlyInstanceOf(TestServiceInstanceService.class);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void clientCredentialsNotAllowedWhenUsernameAndPasswordSet() {
|
||||
assertThatThrownBy(() -> this.contextRunner
|
||||
.withPropertyValues("spring.cloud.appbroker.deployer.cloudfoundry.api-host=https://api.example.local",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.username=user",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.password=secret",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.client_id=user",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.client_secret=secret")
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.username=user",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.password=secret",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.client_id=user",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.client_secret=secret")
|
||||
.run(Lifecycle::start));
|
||||
}
|
||||
|
||||
@@ -137,7 +125,7 @@ class AppBrokerAutoConfigurationTest {
|
||||
void clientIdWithoutSecretNotAllowed() {
|
||||
assertThatThrownBy(() -> this.contextRunner
|
||||
.withPropertyValues("spring.cloud.appbroker.deployer.cloudfoundry.api-host=https://api.example.local",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.client_id=user")
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.client_id=user")
|
||||
.run(Lifecycle::start));
|
||||
}
|
||||
|
||||
@@ -145,9 +133,9 @@ class AppBrokerAutoConfigurationTest {
|
||||
void configureCloudFoundryClientWithClientCredentials() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("spring.cloud.appbroker.deployer.cloudfoundry.api-host=https://api.example.local",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.client_id=user",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.client_secret=secret")
|
||||
.run(context -> {
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.client_id=user",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.client_secret=secret")
|
||||
.run((context) -> {
|
||||
assertThat(context).hasSingleBean(TokenProvider.class);
|
||||
assertThat(context).hasSingleBean(ReactorCloudFoundryClient.class);
|
||||
});
|
||||
@@ -155,50 +143,39 @@ class AppBrokerAutoConfigurationTest {
|
||||
|
||||
@Test
|
||||
void serviceInstanceStateRepositoryIsNotCreatedIfProvided() {
|
||||
configuredContext()
|
||||
.withUserConfiguration(CustomStateRepositoriesConfiguration.class)
|
||||
.run(context -> {
|
||||
assertBeansCreated(context);
|
||||
configuredContext().withUserConfiguration(CustomStateRepositoriesConfiguration.class).run((context) -> {
|
||||
assertBeansCreated(context);
|
||||
|
||||
assertThat(context)
|
||||
.hasSingleBean(ServiceInstanceStateRepository.class)
|
||||
.getBean(ServiceInstanceStateRepository.class)
|
||||
.isExactlyInstanceOf(TestServiceInstanceStateRepository.class);
|
||||
});
|
||||
assertThat(context).hasSingleBean(ServiceInstanceStateRepository.class)
|
||||
.getBean(ServiceInstanceStateRepository.class)
|
||||
.isExactlyInstanceOf(TestServiceInstanceStateRepository.class);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void brokeredServicesIsNotCreatedIfProvided() {
|
||||
configuredContext()
|
||||
.withUserConfiguration(CustomBrokeredServicesConfiguration.class)
|
||||
.run(context -> {
|
||||
assertBeansCreated(context);
|
||||
configuredContext().withUserConfiguration(CustomBrokeredServicesConfiguration.class).run((context) -> {
|
||||
assertBeansCreated(context);
|
||||
|
||||
assertThat(context)
|
||||
.hasSingleBean(BrokeredServices.class)
|
||||
.getBean(BrokeredServices.class)
|
||||
.isEqualTo(new CustomBrokeredServicesConfiguration().brokeredServices());
|
||||
});
|
||||
assertThat(context).hasSingleBean(BrokeredServices.class)
|
||||
.getBean(BrokeredServices.class)
|
||||
.isEqualTo(new CustomBrokeredServicesConfiguration().brokeredServices());
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void serviceInstanceBindingStateRepositoryIsNotCreatedIfProvided() {
|
||||
configuredContext()
|
||||
.withUserConfiguration(CustomStateRepositoriesConfiguration.class)
|
||||
.run(context -> {
|
||||
assertBeansCreated(context);
|
||||
configuredContext().withUserConfiguration(CustomStateRepositoriesConfiguration.class).run((context) -> {
|
||||
assertBeansCreated(context);
|
||||
|
||||
assertThat(context)
|
||||
.hasSingleBean(ServiceInstanceBindingStateRepository.class)
|
||||
.getBean(ServiceInstanceBindingStateRepository.class)
|
||||
.isExactlyInstanceOf(TestServiceInstanceBindingStateRepository.class);
|
||||
});
|
||||
assertThat(context).hasSingleBean(ServiceInstanceBindingStateRepository.class)
|
||||
.getBean(ServiceInstanceBindingStateRepository.class)
|
||||
.isExactlyInstanceOf(TestServiceInstanceBindingStateRepository.class);
|
||||
});
|
||||
}
|
||||
|
||||
private ApplicationContextRunner configuredContext() {
|
||||
return this.contextRunner
|
||||
.withPropertyValues(
|
||||
"spring.cloud.appbroker.services[0].service-name=service1",
|
||||
return this.contextRunner.withPropertyValues("spring.cloud.appbroker.services[0].service-name=service1",
|
||||
"spring.cloud.appbroker.services[0].plan-name=service1-plan1",
|
||||
|
||||
"spring.cloud.appbroker.services[0].apps[0].path=classpath:app1.jar",
|
||||
@@ -220,8 +197,7 @@ class AppBrokerAutoConfigurationTest {
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.username=user",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.password=secret",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.staging-timeout=3",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.deployment-timeout=4"
|
||||
);
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.deployment-timeout=4");
|
||||
}
|
||||
|
||||
private void assertBeansCreated(AssertableApplicationContext context) {
|
||||
@@ -312,13 +288,11 @@ class AppBrokerAutoConfigurationTest {
|
||||
|
||||
@Bean
|
||||
public BrokeredServices brokeredServices() {
|
||||
return BrokeredServices.builder().service(
|
||||
BrokeredService.builder()
|
||||
.serviceName("single-service")
|
||||
.planName("service1-plan1")
|
||||
.build())
|
||||
return BrokeredServices.builder()
|
||||
.service(BrokeredService.builder().serviceName("single-service").planName("service1-plan1").build())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@@ -337,6 +311,7 @@ class AppBrokerAutoConfigurationTest {
|
||||
}
|
||||
|
||||
private static class TestServiceInstanceBindingService implements ServiceInstanceBindingService {
|
||||
|
||||
}
|
||||
|
||||
private static class TestServiceInstanceService implements ServiceInstanceService {
|
||||
@@ -353,8 +328,12 @@ class AppBrokerAutoConfigurationTest {
|
||||
|
||||
}
|
||||
|
||||
private static class TestServiceInstanceStateRepository implements ServiceInstanceStateRepository {}
|
||||
private static class TestServiceInstanceStateRepository implements ServiceInstanceStateRepository {
|
||||
|
||||
private static class TestServiceInstanceBindingStateRepository implements ServiceInstanceBindingStateRepository {}
|
||||
}
|
||||
|
||||
private static class TestServiceInstanceBindingStateRepository implements ServiceInstanceBindingStateRepository {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,7 +38,7 @@ import org.springframework.cloud.appbroker.deployer.oauth2.OAuth2Client;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class CloudFoundryAppDeployerAutoConfigurationTest {
|
||||
class CloudFoundryAppDeployerAutoConfigurationTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(CloudFoundryAppDeployerAutoConfiguration.class));
|
||||
@@ -46,19 +46,17 @@ class CloudFoundryAppDeployerAutoConfigurationTest {
|
||||
@Test
|
||||
void clientIsCreatedWithPasswordGrantConfiguration() {
|
||||
this.contextRunner
|
||||
.withPropertyValues(
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.api-host=api.example.local",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.api-port=443",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.default-org=example-org",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.default-space=example-space",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.username=user",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.password=secret",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.properties.memory=2G",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.properties.count=3",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.properties.buildpack=example-buildpack",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.properties.stack=customstack",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.properties.domain=example.local"
|
||||
)
|
||||
.withPropertyValues("spring.cloud.appbroker.deployer.cloudfoundry.api-host=api.example.local",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.api-port=443",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.default-org=example-org",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.default-space=example-space",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.username=user",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.password=secret",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.properties.memory=2G",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.properties.count=3",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.properties.buildpack=example-buildpack",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.properties.stack=customstack",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.properties.domain=example.local")
|
||||
.run((context) -> {
|
||||
assertThat(context).hasSingleBean(CloudFoundryTargetProperties.class);
|
||||
CloudFoundryTargetProperties targetProperties = context.getBean(CloudFoundryTargetProperties.class);
|
||||
@@ -95,14 +93,12 @@ class CloudFoundryAppDeployerAutoConfigurationTest {
|
||||
@Test
|
||||
void clientIsCreatedWithCredentialsGrantConfiguration() {
|
||||
this.contextRunner
|
||||
.withPropertyValues(
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.api-host=api.example.local",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.api-port=443",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.default-org=example-org",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.default-space=example-space",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.client-id=oauth-client",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.client-secret=secret"
|
||||
)
|
||||
.withPropertyValues("spring.cloud.appbroker.deployer.cloudfoundry.api-host=api.example.local",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.api-port=443",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.default-org=example-org",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.default-space=example-space",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.client-id=oauth-client",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.client-secret=secret")
|
||||
.run((context) -> {
|
||||
assertThat(context).hasSingleBean(CloudFoundryTargetProperties.class);
|
||||
CloudFoundryTargetProperties targetProperties = context.getBean(CloudFoundryTargetProperties.class);
|
||||
@@ -128,18 +124,17 @@ class CloudFoundryAppDeployerAutoConfigurationTest {
|
||||
|
||||
@Test
|
||||
void clientIsNotCreatedWithoutConfiguration() {
|
||||
this.contextRunner
|
||||
.run((context) -> {
|
||||
assertThat(context).doesNotHaveBean(CloudFoundryTargetProperties.class);
|
||||
assertThat(context).doesNotHaveBean(CloudFoundryDeploymentProperties.class);
|
||||
assertThat(context).doesNotHaveBean(ReactorCloudFoundryClient.class);
|
||||
assertThat(context).doesNotHaveBean(ReactorDopplerClient.class);
|
||||
assertThat(context).doesNotHaveBean(ReactorUaaClient.class);
|
||||
assertThat(context).doesNotHaveBean(CloudFoundryOperations.class);
|
||||
assertThat(context).doesNotHaveBean(CloudFoundryOperationsUtils.class);
|
||||
assertThat(context).doesNotHaveBean(ConnectionContext.class);
|
||||
assertThat(context).doesNotHaveBean(TokenProvider.class);
|
||||
});
|
||||
this.contextRunner.run((context) -> {
|
||||
assertThat(context).doesNotHaveBean(CloudFoundryTargetProperties.class);
|
||||
assertThat(context).doesNotHaveBean(CloudFoundryDeploymentProperties.class);
|
||||
assertThat(context).doesNotHaveBean(ReactorCloudFoundryClient.class);
|
||||
assertThat(context).doesNotHaveBean(ReactorDopplerClient.class);
|
||||
assertThat(context).doesNotHaveBean(ReactorUaaClient.class);
|
||||
assertThat(context).doesNotHaveBean(CloudFoundryOperations.class);
|
||||
assertThat(context).doesNotHaveBean(CloudFoundryOperationsUtils.class);
|
||||
assertThat(context).doesNotHaveBean(ConnectionContext.class);
|
||||
assertThat(context).doesNotHaveBean(TokenProvider.class);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,27 +33,20 @@ import org.springframework.web.reactive.socket.server.support.WebSocketHandlerAd
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class ServiceInstanceLogStreamAutoConfigurationTest {
|
||||
class ServiceInstanceLogStreamAutoConfigurationTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(
|
||||
AppBrokerAutoConfiguration.class,
|
||||
CloudFoundryAppDeployerAutoConfiguration.class,
|
||||
ServiceInstanceLogStreamAutoConfiguration.class
|
||||
))
|
||||
.withPropertyValues(
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.api-host=https://api.example.local",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.username=user",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.password=secret"
|
||||
);
|
||||
.withConfiguration(AutoConfigurations.of(AppBrokerAutoConfiguration.class,
|
||||
CloudFoundryAppDeployerAutoConfiguration.class, ServiceInstanceLogStreamAutoConfiguration.class))
|
||||
.withPropertyValues("spring.cloud.appbroker.deployer.cloudfoundry.api-host=https://api.example.local",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.username=user",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.password=secret");
|
||||
|
||||
@Test
|
||||
void servicesAreNotCreatedWhenPublisherIsNotConfigured() {
|
||||
contextRunner
|
||||
.withClassLoader(new FilteredClassLoader(ApplicationLogStreamPublisher.class))
|
||||
this.contextRunner.withClassLoader(new FilteredClassLoader(ApplicationLogStreamPublisher.class))
|
||||
.withUserConfiguration(LoggingConfiguration.class)
|
||||
.run(context -> assertThat(context)
|
||||
.doesNotHaveBean(StreamingLogWebSocketHandler.class)
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(StreamingLogWebSocketHandler.class)
|
||||
.doesNotHaveBean(WebSocketHandlerAdapter.class)
|
||||
.doesNotHaveBean(HandlerMapping.class)
|
||||
.doesNotHaveBean(LogStreamPublisher.class)
|
||||
@@ -62,21 +55,17 @@ class ServiceInstanceLogStreamAutoConfigurationTest {
|
||||
|
||||
@Test
|
||||
void servicesAreNotCreatedWhenLoggingIsNotConfigured() {
|
||||
contextRunner
|
||||
.run(context -> assertThat(context)
|
||||
.doesNotHaveBean(StreamingLogWebSocketHandler.class)
|
||||
.doesNotHaveBean(WebSocketHandlerAdapter.class)
|
||||
.doesNotHaveBean(HandlerMapping.class)
|
||||
.doesNotHaveBean(LogStreamPublisher.class)
|
||||
.doesNotHaveBean(ApplicationLogStreamPublisher.class));
|
||||
this.contextRunner.run((context) -> assertThat(context).doesNotHaveBean(StreamingLogWebSocketHandler.class)
|
||||
.doesNotHaveBean(WebSocketHandlerAdapter.class)
|
||||
.doesNotHaveBean(HandlerMapping.class)
|
||||
.doesNotHaveBean(LogStreamPublisher.class)
|
||||
.doesNotHaveBean(ApplicationLogStreamPublisher.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void servicesAreCreatedWithLoggingConfigured() {
|
||||
contextRunner
|
||||
.withUserConfiguration(LoggingConfiguration.class)
|
||||
.run(context -> assertThat(context)
|
||||
.hasSingleBean(StreamingLogWebSocketHandler.class)
|
||||
this.contextRunner.withUserConfiguration(LoggingConfiguration.class)
|
||||
.run((context) -> assertThat(context).hasSingleBean(StreamingLogWebSocketHandler.class)
|
||||
.hasSingleBean(WebSocketHandlerAdapter.class)
|
||||
.hasSingleBean(HandlerMapping.class)
|
||||
.hasSingleBean(LogStreamPublisher.class)
|
||||
@@ -88,7 +77,7 @@ class ServiceInstanceLogStreamAutoConfigurationTest {
|
||||
|
||||
@Bean
|
||||
public ApplicationIdsProvider applicationIdsProvider() {
|
||||
return serviceInstanceId -> Flux.just("app1");
|
||||
return (serviceInstanceId) -> Flux.just("app1");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,44 +31,33 @@ import org.springframework.context.annotation.Bean;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class ServiceInstanceRecentLogsAutoConfigurationTest {
|
||||
class ServiceInstanceRecentLogsAutoConfigurationTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(
|
||||
AppBrokerAutoConfiguration.class,
|
||||
CloudFoundryAppDeployerAutoConfiguration.class,
|
||||
ServiceInstanceRecentLogsAutoConfiguration.class
|
||||
))
|
||||
.withPropertyValues(
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.api-host=https://api.example.local",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.username=user",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.password=secret"
|
||||
);
|
||||
.withConfiguration(AutoConfigurations.of(AppBrokerAutoConfiguration.class,
|
||||
CloudFoundryAppDeployerAutoConfiguration.class, ServiceInstanceRecentLogsAutoConfiguration.class))
|
||||
.withPropertyValues("spring.cloud.appbroker.deployer.cloudfoundry.api-host=https://api.example.local",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.username=user",
|
||||
"spring.cloud.appbroker.deployer.cloudfoundry.password=secret");
|
||||
|
||||
@Test
|
||||
void servicesAreNotCreatedWithoutLoggingOnClasspath() {
|
||||
contextRunner
|
||||
.withClassLoader(new FilteredClassLoader(ApplicationRecentLogsProvider.class))
|
||||
this.contextRunner.withClassLoader(new FilteredClassLoader(ApplicationRecentLogsProvider.class))
|
||||
.withUserConfiguration(LoggingConfiguration.class)
|
||||
.run(context -> assertThat(context)
|
||||
.doesNotHaveBean(RecentLogsProvider.class)
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(RecentLogsProvider.class)
|
||||
.doesNotHaveBean(RecentLogsController.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void servicesAreNotCreatedWithoutRequiredBeansOnClasspath() {
|
||||
contextRunner
|
||||
.run(context -> assertThat(context)
|
||||
.doesNotHaveBean(RecentLogsProvider.class)
|
||||
.doesNotHaveBean(RecentLogsController.class));
|
||||
this.contextRunner.run((context) -> assertThat(context).doesNotHaveBean(RecentLogsProvider.class)
|
||||
.doesNotHaveBean(RecentLogsController.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void servicesAreCreatedWithLoggingConfigured() {
|
||||
contextRunner
|
||||
.withUserConfiguration(LoggingConfiguration.class)
|
||||
.run(context -> assertThat(context)
|
||||
.hasSingleBean(RecentLogsProvider.class)
|
||||
this.contextRunner.withUserConfiguration(LoggingConfiguration.class)
|
||||
.run((context) -> assertThat(context).hasSingleBean(RecentLogsProvider.class)
|
||||
.hasSingleBean(RecentLogsController.class));
|
||||
}
|
||||
|
||||
@@ -77,7 +66,7 @@ class ServiceInstanceRecentLogsAutoConfigurationTest {
|
||||
|
||||
@Bean
|
||||
public ApplicationIdsProvider applicationIdsProvider() {
|
||||
return serviceInstanceId -> Flux.just("app1");
|
||||
return (serviceInstanceId) -> Flux.just("app1");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import org.springframework.boot.gradle.plugin.SpringBootPlugin
|
||||
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -21,45 +21,52 @@ import java.util.List;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
/**
|
||||
* This interface is implemented by service brokers to process requests to deploy, update, and undeploy backing
|
||||
* applications associated with a service instance.
|
||||
* This interface is implemented by service brokers to process requests to deploy, update,
|
||||
* and undeploy backing applications associated with a service instance.
|
||||
*
|
||||
* @author Scott Frederick
|
||||
* @author Roy Clarkson
|
||||
* @author Oliver Hughes
|
||||
* @author Alexey Nesterov
|
||||
* @author Gareth Clay
|
||||
*/
|
||||
public interface BackingAppDeploymentService {
|
||||
|
||||
/**
|
||||
* Deploy the backing applications and associate with the service instance
|
||||
*
|
||||
* Deploy the backing applications and associate with the service instance.
|
||||
* @param backingApps a collection of backing applications
|
||||
* @param serviceInstanceId the service instance ID
|
||||
* @return a set of strings, where each corresponds to an application e.g. the application name
|
||||
* @return a set of strings, where each corresponds to an application e.g. the
|
||||
* application name
|
||||
*/
|
||||
Flux<String> deploy(List<BackingApplication> backingApps, String serviceInstanceId);
|
||||
|
||||
/**
|
||||
* Performs any steps necessary prior to backing application and backing service updates
|
||||
*
|
||||
* Performs any steps necessary prior to backing application and backing service
|
||||
* updates.
|
||||
* @param backingApps a collection of backing applications
|
||||
* @param serviceInstanceId the service instance ID
|
||||
* @return a set of strings, where each corresponds to an application. e.g. the application name
|
||||
* @return a set of strings, where each corresponds to an application. e.g. the
|
||||
* application name
|
||||
*/
|
||||
default Flux<String> prepareForUpdate(List<BackingApplication> backingApps, String serviceInstanceId) {
|
||||
return Flux.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the backing applications and associate with the service instance
|
||||
*
|
||||
* Update the backing applications and associate with the service instance.
|
||||
* @param backingApps a collection of backing applications
|
||||
* @param serviceInstanceId the service instance ID
|
||||
* @return a set of strings, where each corresponds to an application. e.g. the application name
|
||||
* @return a set of strings, where each corresponds to an application. e.g. the
|
||||
* application name
|
||||
*/
|
||||
Flux<String> update(List<BackingApplication> backingApps, String serviceInstanceId);
|
||||
|
||||
/**
|
||||
* Undeploy the backing applications
|
||||
*
|
||||
* Undeploy the backing applications.
|
||||
* @param backingApps a collection of backing applications
|
||||
* @return a set of strings, where each corresponds to an application. e.g. the application name
|
||||
* @return a set of strings, where each corresponds to an application. e.g. the
|
||||
* application name
|
||||
*/
|
||||
Flux<String> undeploy(List<BackingApplication> backingApps);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -27,7 +27,13 @@ import java.util.stream.Collectors;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
* An application deployed as part of the service provisioning process
|
||||
* An application deployed as part of the service provisioning process.
|
||||
*
|
||||
* @author Scott Frederick
|
||||
* @author Roy Clarkson
|
||||
* @author Oliver Hughes
|
||||
* @author Alexey Nesterov
|
||||
* @author Alberto Rios
|
||||
*/
|
||||
public class BackingApplication {
|
||||
|
||||
@@ -49,8 +55,7 @@ public class BackingApplication {
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new {@link BackingApplication}
|
||||
*
|
||||
* Construct a new {@link BackingApplication}.
|
||||
* @param name the name of the application
|
||||
* @param path the path to the application
|
||||
* @param properties the properties
|
||||
@@ -58,11 +63,8 @@ public class BackingApplication {
|
||||
* @param services the services required by the application
|
||||
* @param parametersTransformers the parameter transformers
|
||||
*/
|
||||
public BackingApplication(String name, String path,
|
||||
Map<String, String> properties,
|
||||
Map<String, Object> environment,
|
||||
List<ServicesSpec> services,
|
||||
List<ParametersTransformerSpec> parametersTransformers) {
|
||||
public BackingApplication(String name, String path, Map<String, String> properties, Map<String, Object> environment,
|
||||
List<ServicesSpec> services, List<ParametersTransformerSpec> parametersTransformers) {
|
||||
this.name = name;
|
||||
this.path = path;
|
||||
this.properties = properties;
|
||||
@@ -72,7 +74,7 @@ public class BackingApplication {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
@@ -80,7 +82,7 @@ public class BackingApplication {
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
return this.path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
@@ -88,7 +90,7 @@ public class BackingApplication {
|
||||
}
|
||||
|
||||
public Map<String, String> getProperties() {
|
||||
return properties;
|
||||
return this.properties;
|
||||
}
|
||||
|
||||
public void setProperties(Map<String, String> properties) {
|
||||
@@ -96,8 +98,7 @@ public class BackingApplication {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a single property
|
||||
*
|
||||
* Add a single property.
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
@@ -106,7 +107,7 @@ public class BackingApplication {
|
||||
}
|
||||
|
||||
public Map<String, Object> getEnvironment() {
|
||||
return environment;
|
||||
return this.environment;
|
||||
}
|
||||
|
||||
public void setEnvironment(Map<String, Object> environment) {
|
||||
@@ -114,17 +115,16 @@ public class BackingApplication {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a single environment value
|
||||
*
|
||||
* Add a single environment value.
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
public void addEnvironment(String key, Object value) {
|
||||
environment.put(key, value);
|
||||
this.environment.put(key, value);
|
||||
}
|
||||
|
||||
public List<ServicesSpec> getServices() {
|
||||
return services;
|
||||
return this.services;
|
||||
}
|
||||
|
||||
public void setServices(List<ServicesSpec> services) {
|
||||
@@ -132,7 +132,7 @@ public class BackingApplication {
|
||||
}
|
||||
|
||||
public List<ParametersTransformerSpec> getParametersTransformers() {
|
||||
return parametersTransformers;
|
||||
return this.parametersTransformers;
|
||||
}
|
||||
|
||||
public void setParametersTransformers(List<ParametersTransformerSpec> parametersTransformers) {
|
||||
@@ -140,8 +140,8 @@ public class BackingApplication {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder that provides a fluent API for constructing a {@literal BackingApplication}.
|
||||
*
|
||||
* Create a builder that provides a fluent API for constructing a
|
||||
* {@literal BackingApplication}.
|
||||
* @return the builder
|
||||
*/
|
||||
public static BackingApplicationBuilder builder() {
|
||||
@@ -157,29 +157,23 @@ public class BackingApplication {
|
||||
return false;
|
||||
}
|
||||
BackingApplication that = (BackingApplication) o;
|
||||
return Objects.equals(name, that.name) &&
|
||||
Objects.equals(path, that.path) &&
|
||||
Objects.equals(properties, that.properties) &&
|
||||
Objects.equals(environment, that.environment) &&
|
||||
Objects.equals(services, that.services) &&
|
||||
Objects.equals(parametersTransformers, that.parametersTransformers);
|
||||
return Objects.equals(this.name, that.name) && Objects.equals(this.path, that.path)
|
||||
&& Objects.equals(this.properties, that.properties)
|
||||
&& Objects.equals(this.environment, that.environment) && Objects.equals(this.services, that.services)
|
||||
&& Objects.equals(this.parametersTransformers, that.parametersTransformers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
return Objects.hash(name, path, properties, environment, services, parametersTransformers);
|
||||
return Objects.hash(this.name, this.path, this.properties, this.environment, this.services,
|
||||
this.parametersTransformers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BackingApplication{" +
|
||||
"name='" + name + '\'' +
|
||||
", path='" + path + '\'' +
|
||||
", properties=" + properties +
|
||||
", environment=" + sanitizeEnvironment(environment) +
|
||||
", services=" + services +
|
||||
", parametersTransformers=" + parametersTransformers +
|
||||
'}';
|
||||
return "BackingApplication{" + "name='" + this.name + '\'' + ", path='" + this.path + '\'' + ", properties="
|
||||
+ this.properties + ", environment=" + sanitizeEnvironment(this.environment) + ", services="
|
||||
+ this.services + ", parametersTransformers=" + this.parametersTransformers + '}';
|
||||
}
|
||||
|
||||
private Map<String, Object> sanitizeEnvironment(Map<String, Object> environment) {
|
||||
@@ -214,8 +208,7 @@ public class BackingApplication {
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a backing application based on another application definition
|
||||
*
|
||||
* Build a backing application based on another application definition.
|
||||
* @param backingApplication the backing application from which to copy properties
|
||||
* @return the builder
|
||||
*/
|
||||
@@ -225,25 +218,22 @@ public class BackingApplication {
|
||||
.properties(backingApplication.getProperties())
|
||||
.environment(backingApplication.getEnvironment());
|
||||
if (!CollectionUtils.isEmpty(backingApplication.getServices())) {
|
||||
this.services(backingApplication.getServices().stream()
|
||||
.map(spec -> ServicesSpec.builder()
|
||||
.spec(spec)
|
||||
.build())
|
||||
this.services(backingApplication.getServices()
|
||||
.stream()
|
||||
.map((spec) -> ServicesSpec.builder().spec(spec).build())
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(backingApplication.getParametersTransformers())) {
|
||||
this.parameterTransformers(backingApplication.getParametersTransformers().stream()
|
||||
.map(spec -> ParametersTransformerSpec.builder()
|
||||
.spec(spec)
|
||||
.build())
|
||||
this.parameterTransformers(backingApplication.getParametersTransformers()
|
||||
.stream()
|
||||
.map((spec) -> ParametersTransformerSpec.builder().spec(spec).build())
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the application
|
||||
*
|
||||
* The name of the application.
|
||||
* @param name the name
|
||||
* @return the builder
|
||||
*/
|
||||
@@ -253,8 +243,7 @@ public class BackingApplication {
|
||||
}
|
||||
|
||||
/**
|
||||
* The path to the application
|
||||
*
|
||||
* The path to the application.
|
||||
* @param path the path
|
||||
* @return the builder
|
||||
*/
|
||||
@@ -264,8 +253,7 @@ public class BackingApplication {
|
||||
}
|
||||
|
||||
/**
|
||||
* Properties that describe the application
|
||||
*
|
||||
* Properties that describe the application.
|
||||
* @param key the property key
|
||||
* @param value the property value
|
||||
* @return the builder
|
||||
@@ -278,8 +266,7 @@ public class BackingApplication {
|
||||
}
|
||||
|
||||
/**
|
||||
* Properties that describe the application
|
||||
*
|
||||
* Properties that describe the application.
|
||||
* @param properties the properties
|
||||
* @return the builder
|
||||
*/
|
||||
@@ -291,8 +278,7 @@ public class BackingApplication {
|
||||
}
|
||||
|
||||
/**
|
||||
* Environment variables to be set for the application
|
||||
*
|
||||
* Environment variables to be set for the application.
|
||||
* @param key the env var key
|
||||
* @param value the env var value
|
||||
* @return the builder
|
||||
@@ -305,8 +291,7 @@ public class BackingApplication {
|
||||
}
|
||||
|
||||
/**
|
||||
* Environment variables to be set for the application
|
||||
*
|
||||
* Environment variables to be set for the application.
|
||||
* @param environment the env vars
|
||||
* @return the builder
|
||||
*/
|
||||
@@ -318,8 +303,7 @@ public class BackingApplication {
|
||||
}
|
||||
|
||||
/**
|
||||
* Services required by the application
|
||||
*
|
||||
* Services required by the application.
|
||||
* @param services the services
|
||||
* @return the builder
|
||||
*/
|
||||
@@ -331,8 +315,7 @@ public class BackingApplication {
|
||||
}
|
||||
|
||||
/**
|
||||
* Services required by the application
|
||||
*
|
||||
* Services required by the application.
|
||||
* @param services the services
|
||||
* @return the builder
|
||||
*/
|
||||
@@ -344,8 +327,7 @@ public class BackingApplication {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameter transformers for the application
|
||||
*
|
||||
* Parameter transformers for the application.
|
||||
* @param parameterTransformers the parameter transformers
|
||||
* @return the builder
|
||||
*/
|
||||
@@ -357,8 +339,7 @@ public class BackingApplication {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameter transformers for the application
|
||||
*
|
||||
* Parameter transformers for the application.
|
||||
* @param parameterTransformers the parameter transformers
|
||||
* @return the builder
|
||||
*/
|
||||
@@ -371,11 +352,11 @@ public class BackingApplication {
|
||||
|
||||
/**
|
||||
* Construct a {@link BackingApplication} from the provided values.
|
||||
*
|
||||
* @return the newly constructed {@literal BackingApplication}
|
||||
*/
|
||||
public BackingApplication build() {
|
||||
return new BackingApplication(name, path, properties, environment, services, parameterTransformers);
|
||||
return new BackingApplication(this.name, this.path, this.properties, this.environment, this.services,
|
||||
this.parameterTransformers);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -51,15 +51,14 @@ public class BackingApplications extends ArrayList<BackingApplication> {
|
||||
|
||||
public BackingApplicationsBuilder backingApplications(List<BackingApplication> backingApplications) {
|
||||
if (!CollectionUtils.isEmpty(backingApplications)) {
|
||||
backingApplications.forEach(backingApplication -> this.backingApplication(BackingApplication.builder()
|
||||
.backingApplication(backingApplication)
|
||||
.build()));
|
||||
backingApplications.forEach((backingApplication) -> this
|
||||
.backingApplication(BackingApplication.builder().backingApplication(backingApplication).build()));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public BackingApplications build() {
|
||||
return new BackingApplications(backingApplications);
|
||||
return new BackingApplications(this.backingApplications);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -45,13 +45,9 @@ public class BackingService {
|
||||
private BackingService() {
|
||||
}
|
||||
|
||||
public BackingService(String serviceInstanceName,
|
||||
String name,
|
||||
String plan,
|
||||
Map<String, Object> parameters,
|
||||
Map<String, String> properties,
|
||||
List<ParametersTransformerSpec> parametersTransformers,
|
||||
boolean rebindOnUpdate) {
|
||||
public BackingService(String serviceInstanceName, String name, String plan, Map<String, Object> parameters,
|
||||
Map<String, String> properties, List<ParametersTransformerSpec> parametersTransformers,
|
||||
boolean rebindOnUpdate) {
|
||||
this.serviceInstanceName = serviceInstanceName;
|
||||
this.name = name;
|
||||
this.plan = plan;
|
||||
@@ -62,7 +58,7 @@ public class BackingService {
|
||||
}
|
||||
|
||||
public String getServiceInstanceName() {
|
||||
return serviceInstanceName;
|
||||
return this.serviceInstanceName;
|
||||
}
|
||||
|
||||
public void setServiceInstanceName(String serviceInstanceName) {
|
||||
@@ -70,7 +66,7 @@ public class BackingService {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
@@ -78,7 +74,7 @@ public class BackingService {
|
||||
}
|
||||
|
||||
public String getPlan() {
|
||||
return plan;
|
||||
return this.plan;
|
||||
}
|
||||
|
||||
public void setPlan(String plan) {
|
||||
@@ -86,7 +82,7 @@ public class BackingService {
|
||||
}
|
||||
|
||||
public Map<String, Object> getParameters() {
|
||||
return parameters;
|
||||
return this.parameters;
|
||||
}
|
||||
|
||||
public void setParameters(Map<String, Object> parameters) {
|
||||
@@ -94,11 +90,11 @@ public class BackingService {
|
||||
}
|
||||
|
||||
public void addParameter(String key, Object value) {
|
||||
parameters.put(key, value);
|
||||
this.parameters.put(key, value);
|
||||
}
|
||||
|
||||
public Map<String, String> getProperties() {
|
||||
return properties;
|
||||
return this.properties;
|
||||
}
|
||||
|
||||
public void setProperties(Map<String, String> properties) {
|
||||
@@ -106,7 +102,7 @@ public class BackingService {
|
||||
}
|
||||
|
||||
public List<ParametersTransformerSpec> getParametersTransformers() {
|
||||
return parametersTransformers;
|
||||
return this.parametersTransformers;
|
||||
}
|
||||
|
||||
public void setParametersTransformers(List<ParametersTransformerSpec> parametersTransformers) {
|
||||
@@ -114,7 +110,7 @@ public class BackingService {
|
||||
}
|
||||
|
||||
public boolean isRebindOnUpdate() {
|
||||
return rebindOnUpdate;
|
||||
return this.rebindOnUpdate;
|
||||
}
|
||||
|
||||
public void setRebindOnUpdate(boolean rebindOnUpdate) {
|
||||
@@ -123,10 +119,10 @@ public class BackingService {
|
||||
|
||||
public int serviceInstanceNameAndSpaceHashCode() {
|
||||
String space = null;
|
||||
if (!CollectionUtils.isEmpty(properties)) {
|
||||
space = properties.get(DeploymentProperties.TARGET_PROPERTY_KEY);
|
||||
if (!CollectionUtils.isEmpty(this.properties)) {
|
||||
space = this.properties.get(DeploymentProperties.TARGET_PROPERTY_KEY);
|
||||
}
|
||||
return Objects.hash(serviceInstanceName, space);
|
||||
return Objects.hash(this.serviceInstanceName, space);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,32 +134,25 @@ public class BackingService {
|
||||
return false;
|
||||
}
|
||||
BackingService that = (BackingService) o;
|
||||
return Objects.equals(serviceInstanceName, that.serviceInstanceName) &&
|
||||
Objects.equals(name, that.name) &&
|
||||
Objects.equals(plan, that.plan) &&
|
||||
Objects.equals(parameters, that.parameters) &&
|
||||
Objects.equals(properties, that.properties) &&
|
||||
Objects.equals(parametersTransformers, that.parametersTransformers) &&
|
||||
rebindOnUpdate == that.rebindOnUpdate;
|
||||
return Objects.equals(this.serviceInstanceName, that.serviceInstanceName)
|
||||
&& Objects.equals(this.name, that.name) && Objects.equals(this.plan, that.plan)
|
||||
&& Objects.equals(this.parameters, that.parameters) && Objects.equals(this.properties, that.properties)
|
||||
&& Objects.equals(this.parametersTransformers, that.parametersTransformers)
|
||||
&& this.rebindOnUpdate == that.rebindOnUpdate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects
|
||||
.hash(serviceInstanceName, name, plan, parameters, properties, parametersTransformers, rebindOnUpdate);
|
||||
return Objects.hash(this.serviceInstanceName, this.name, this.plan, this.parameters, this.properties,
|
||||
this.parametersTransformers, this.rebindOnUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BackingService{" +
|
||||
"serviceInstanceName='" + serviceInstanceName + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", plan='" + plan + '\'' +
|
||||
", parameters=" + parameters +
|
||||
", properties=" + properties +
|
||||
", parametersTransformers=" + parametersTransformers +
|
||||
", rebindOnUpdate=" + rebindOnUpdate +
|
||||
'}';
|
||||
return "BackingService{" + "serviceInstanceName='" + this.serviceInstanceName + '\'' + ", name='" + this.name
|
||||
+ '\'' + ", plan='" + this.plan + '\'' + ", parameters=" + this.parameters + ", properties="
|
||||
+ this.properties + ", parametersTransformers=" + this.parametersTransformers + ", rebindOnUpdate="
|
||||
+ this.rebindOnUpdate + '}';
|
||||
}
|
||||
|
||||
public static BackingServiceBuilder builder() {
|
||||
@@ -248,8 +237,8 @@ public class BackingService {
|
||||
}
|
||||
|
||||
public BackingService build() {
|
||||
return new BackingService(serviceInstanceName, name, plan, parameters, properties, parameterTransformers,
|
||||
rebindOnUpdate);
|
||||
return new BackingService(this.serviceInstanceName, this.name, this.plan, this.parameters, this.properties,
|
||||
this.parameterTransformers, this.rebindOnUpdate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -50,15 +50,14 @@ public class BackingServices extends ArrayList<BackingService> {
|
||||
|
||||
public BackingServicesBuilder backingServices(BackingServices backingServices) {
|
||||
if (!CollectionUtils.isEmpty(backingServices)) {
|
||||
backingServices.forEach(backingService -> this.backingService(BackingService.builder()
|
||||
.backingService(backingService)
|
||||
.build()));
|
||||
backingServices.forEach((backingService) -> this
|
||||
.backingService(BackingService.builder().backingService(backingService).build()));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public BackingServices build() {
|
||||
return new BackingServices(backingServices);
|
||||
return new BackingServices(this.backingServices);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2016-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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -37,7 +37,7 @@ public class BrokeredService {
|
||||
}
|
||||
|
||||
public BrokeredService(String serviceName, String planName, BackingApplications apps, BackingServices services,
|
||||
TargetSpec target) {
|
||||
TargetSpec target) {
|
||||
super();
|
||||
this.serviceName = serviceName;
|
||||
this.planName = planName;
|
||||
@@ -47,7 +47,7 @@ public class BrokeredService {
|
||||
}
|
||||
|
||||
public String getServiceName() {
|
||||
return serviceName;
|
||||
return this.serviceName;
|
||||
}
|
||||
|
||||
public void setServiceName(String serviceName) {
|
||||
@@ -55,7 +55,7 @@ public class BrokeredService {
|
||||
}
|
||||
|
||||
public String getPlanName() {
|
||||
return planName;
|
||||
return this.planName;
|
||||
}
|
||||
|
||||
public void setPlanName(String planName) {
|
||||
@@ -63,7 +63,7 @@ public class BrokeredService {
|
||||
}
|
||||
|
||||
public BackingApplications getApps() {
|
||||
return apps;
|
||||
return this.apps;
|
||||
}
|
||||
|
||||
public void setApps(BackingApplications apps) {
|
||||
@@ -71,7 +71,7 @@ public class BrokeredService {
|
||||
}
|
||||
|
||||
public BackingServices getServices() {
|
||||
return services;
|
||||
return this.services;
|
||||
}
|
||||
|
||||
public void setServices(BackingServices services) {
|
||||
@@ -79,7 +79,7 @@ public class BrokeredService {
|
||||
}
|
||||
|
||||
public TargetSpec getTarget() {
|
||||
return target;
|
||||
return this.target;
|
||||
}
|
||||
|
||||
public void setTarget(TargetSpec target) {
|
||||
@@ -99,27 +99,20 @@ public class BrokeredService {
|
||||
return false;
|
||||
}
|
||||
BrokeredService that = (BrokeredService) o;
|
||||
return Objects.equals(serviceName, that.serviceName) &&
|
||||
Objects.equals(planName, that.planName) &&
|
||||
Objects.equals(apps, that.apps) &&
|
||||
Objects.equals(services, that.services) &&
|
||||
Objects.equals(target, that.target);
|
||||
return Objects.equals(this.serviceName, that.serviceName) && Objects.equals(this.planName, that.planName)
|
||||
&& Objects.equals(this.apps, that.apps) && Objects.equals(this.services, that.services)
|
||||
&& Objects.equals(this.target, that.target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
return Objects.hash(serviceName, planName, apps, services, target);
|
||||
return Objects.hash(this.serviceName, this.planName, this.apps, this.services, this.target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BrokeredService{" +
|
||||
"serviceName='" + serviceName + '\'' +
|
||||
", planName='" + planName + '\'' +
|
||||
", apps=" + apps +
|
||||
", services=" + services +
|
||||
", target=" + target +
|
||||
'}';
|
||||
return "BrokeredService{" + "serviceName='" + this.serviceName + '\'' + ", planName='" + this.planName + '\''
|
||||
+ ", apps=" + this.apps + ", services=" + this.services + ", target=" + this.target + '}';
|
||||
}
|
||||
|
||||
public static class BrokeredServiceBuilder {
|
||||
@@ -155,9 +148,7 @@ public class BrokeredService {
|
||||
|
||||
public BrokeredServiceBuilder services(BackingServices backingServices) {
|
||||
if (!CollectionUtils.isEmpty(backingServices)) {
|
||||
this.backingServices = BackingServices.builder()
|
||||
.backingServices(backingServices)
|
||||
.build();
|
||||
this.backingServices = BackingServices.builder().backingServices(backingServices).build();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -168,7 +159,8 @@ public class BrokeredService {
|
||||
}
|
||||
|
||||
public BrokeredService build() {
|
||||
return new BrokeredService(id, planId, backingApplications, backingServices, target);
|
||||
return new BrokeredService(this.id, this.planId, this.backingApplications, this.backingServices,
|
||||
this.target);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -56,7 +56,7 @@ public class BrokeredServices extends ArrayList<BrokeredService> {
|
||||
}
|
||||
|
||||
public BrokeredServices build() {
|
||||
return new BrokeredServices(brokeredServices);
|
||||
return new BrokeredServices(this.brokeredServices);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -40,9 +40,9 @@ public class DefaultBackingAppDeploymentService implements BackingAppDeploymentS
|
||||
return Flux.fromIterable(backingApps)
|
||||
.parallel()
|
||||
.runOn(Schedulers.parallel())
|
||||
.flatMap(backingApplication -> deployerClient.deploy(backingApplication, serviceInstanceId))
|
||||
.flatMap((backingApplication) -> this.deployerClient.deploy(backingApplication, serviceInstanceId))
|
||||
.sequential()
|
||||
.doOnRequest(l -> {
|
||||
.doOnRequest((l) -> {
|
||||
LOG.info("Deploying applications");
|
||||
LOG.debug(BACKINGAPPS_LOG_TEMPLATE, backingApps);
|
||||
})
|
||||
@@ -50,7 +50,7 @@ public class DefaultBackingAppDeploymentService implements BackingAppDeploymentS
|
||||
LOG.info("Finish deploying applications");
|
||||
LOG.debug(BACKINGAPPS_LOG_TEMPLATE, backingApps);
|
||||
})
|
||||
.doOnError(e -> {
|
||||
.doOnError((e) -> {
|
||||
LOG.error(String.format("Error deploying applications. error=%s", e.getMessage()), e);
|
||||
LOG.debug(BACKINGAPPS_LOG_TEMPLATE, backingApps);
|
||||
});
|
||||
@@ -61,9 +61,9 @@ public class DefaultBackingAppDeploymentService implements BackingAppDeploymentS
|
||||
return Flux.fromIterable(backingApps)
|
||||
.parallel()
|
||||
.runOn(Schedulers.parallel())
|
||||
.flatMap(backingApplication -> deployerClient.preUpdate(backingApplication, serviceInstanceId))
|
||||
.flatMap((backingApplication) -> this.deployerClient.preUpdate(backingApplication, serviceInstanceId))
|
||||
.sequential()
|
||||
.doOnRequest(l -> {
|
||||
.doOnRequest((l) -> {
|
||||
LOG.info("Preparing applications for update");
|
||||
LOG.debug(BACKINGAPPS_LOG_TEMPLATE, backingApps);
|
||||
})
|
||||
@@ -71,7 +71,7 @@ public class DefaultBackingAppDeploymentService implements BackingAppDeploymentS
|
||||
LOG.info("Finish preparing applications for update");
|
||||
LOG.debug(BACKINGAPPS_LOG_TEMPLATE, backingApps);
|
||||
})
|
||||
.doOnError(e -> {
|
||||
.doOnError((e) -> {
|
||||
LOG.error(String.format("Error preparing applications for update. error=%s", e.getMessage()), e);
|
||||
LOG.debug(BACKINGAPPS_LOG_TEMPLATE, backingApps);
|
||||
});
|
||||
@@ -82,9 +82,9 @@ public class DefaultBackingAppDeploymentService implements BackingAppDeploymentS
|
||||
return Flux.fromIterable(backingApps)
|
||||
.parallel()
|
||||
.runOn(Schedulers.parallel())
|
||||
.flatMap(backingApplication -> deployerClient.update(backingApplication, serviceInstanceId))
|
||||
.flatMap((backingApplication) -> this.deployerClient.update(backingApplication, serviceInstanceId))
|
||||
.sequential()
|
||||
.doOnRequest(l -> {
|
||||
.doOnRequest((l) -> {
|
||||
LOG.info("Updating applications");
|
||||
LOG.debug(BACKINGAPPS_LOG_TEMPLATE, backingApps);
|
||||
})
|
||||
@@ -92,7 +92,7 @@ public class DefaultBackingAppDeploymentService implements BackingAppDeploymentS
|
||||
LOG.info("Finish updating applications");
|
||||
LOG.debug(BACKINGAPPS_LOG_TEMPLATE, backingApps);
|
||||
})
|
||||
.doOnError(e -> {
|
||||
.doOnError((e) -> {
|
||||
LOG.error(String.format("Error updating applications. error=%s", e.getMessage()), e);
|
||||
LOG.debug(BACKINGAPPS_LOG_TEMPLATE, backingApps);
|
||||
});
|
||||
@@ -103,9 +103,9 @@ public class DefaultBackingAppDeploymentService implements BackingAppDeploymentS
|
||||
return Flux.fromIterable(backingApps)
|
||||
.parallel()
|
||||
.runOn(Schedulers.parallel())
|
||||
.flatMap(deployerClient::undeploy)
|
||||
.flatMap(this.deployerClient::undeploy)
|
||||
.sequential()
|
||||
.doOnRequest(l -> {
|
||||
.doOnRequest((l) -> {
|
||||
LOG.info("Undeploying applications");
|
||||
LOG.debug(BACKINGAPPS_LOG_TEMPLATE, backingApps);
|
||||
})
|
||||
@@ -113,7 +113,7 @@ public class DefaultBackingAppDeploymentService implements BackingAppDeploymentS
|
||||
LOG.info("Finish undeploying applications");
|
||||
LOG.debug(BACKINGAPPS_LOG_TEMPLATE, backingApps);
|
||||
})
|
||||
.doOnError(e -> {
|
||||
.doOnError((e) -> {
|
||||
LOG.error(String.format("Error undeploying applications. error=%s", e.getMessage()), e);
|
||||
LOG.debug(BACKINGAPPS_LOG_TEMPLATE, backingApps);
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -40,9 +40,9 @@ public class DefaultBackingServicesProvisionService implements BackingServicesPr
|
||||
return Flux.fromIterable(backingServices)
|
||||
.parallel()
|
||||
.runOn(Schedulers.parallel())
|
||||
.flatMap(deployerClient::createServiceInstance)
|
||||
.flatMap(this.deployerClient::createServiceInstance)
|
||||
.sequential()
|
||||
.doOnRequest(l -> {
|
||||
.doOnRequest((l) -> {
|
||||
LOG.info("Creating backing services");
|
||||
LOG.debug(BACKINGSERVICES_LOG_TEMPLATE, backingServices);
|
||||
})
|
||||
@@ -50,7 +50,7 @@ public class DefaultBackingServicesProvisionService implements BackingServicesPr
|
||||
LOG.info("Finish creating backing services");
|
||||
LOG.debug(BACKINGSERVICES_LOG_TEMPLATE, backingServices);
|
||||
})
|
||||
.doOnError(e -> LOG.error(String.format("Error creating backing services. error=%s", e.getMessage()), e));
|
||||
.doOnError((e) -> LOG.error(String.format("Error creating backing services. error=%s", e.getMessage()), e));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,9 +58,9 @@ public class DefaultBackingServicesProvisionService implements BackingServicesPr
|
||||
return Flux.fromIterable(backingServices)
|
||||
.parallel()
|
||||
.runOn(Schedulers.parallel())
|
||||
.flatMap(deployerClient::updateServiceInstance)
|
||||
.flatMap(this.deployerClient::updateServiceInstance)
|
||||
.sequential()
|
||||
.doOnRequest(l -> {
|
||||
.doOnRequest((l) -> {
|
||||
LOG.info("Updating backing services");
|
||||
LOG.debug(BACKINGSERVICES_LOG_TEMPLATE, backingServices);
|
||||
})
|
||||
@@ -68,7 +68,7 @@ public class DefaultBackingServicesProvisionService implements BackingServicesPr
|
||||
LOG.info("Finish updating backing services");
|
||||
LOG.debug(BACKINGSERVICES_LOG_TEMPLATE, backingServices);
|
||||
})
|
||||
.doOnError(e -> LOG.error(String.format("Error updating backing services. error=%s", e.getMessage()), e));
|
||||
.doOnError((e) -> LOG.error(String.format("Error updating backing services. error=%s", e.getMessage()), e));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,9 +76,9 @@ public class DefaultBackingServicesProvisionService implements BackingServicesPr
|
||||
return Flux.fromIterable(backingServices)
|
||||
.parallel()
|
||||
.runOn(Schedulers.parallel())
|
||||
.flatMap(deployerClient::deleteServiceInstance)
|
||||
.flatMap(this.deployerClient::deleteServiceInstance)
|
||||
.sequential()
|
||||
.doOnRequest(l -> {
|
||||
.doOnRequest((l) -> {
|
||||
LOG.info("Deleting backing services");
|
||||
LOG.debug(BACKINGSERVICES_LOG_TEMPLATE, backingServices);
|
||||
})
|
||||
@@ -86,7 +86,7 @@ public class DefaultBackingServicesProvisionService implements BackingServicesPr
|
||||
LOG.info("Finish deleting backing services");
|
||||
LOG.debug(BACKINGSERVICES_LOG_TEMPLATE, backingServices);
|
||||
})
|
||||
.doOnError(e -> LOG.error(String.format("Error deleting backing services. error=%s", e.getMessage()), e));
|
||||
.doOnError((e) -> LOG.error(String.format("Error deleting backing services. error=%s", e.getMessage()), e));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2016-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.
|
||||
@@ -40,9 +40,9 @@ public class DefaultBackingSpaceManagementService implements BackingSpaceManagem
|
||||
return Flux.fromIterable(targetSpaces)
|
||||
.parallel()
|
||||
.runOn(Schedulers.parallel())
|
||||
.flatMap(deployerClient::deleteSpace)
|
||||
.flatMap(this.deployerClient::deleteSpace)
|
||||
.sequential()
|
||||
.doOnRequest(l -> {
|
||||
.doOnRequest((l) -> {
|
||||
LOG.info("Deleting backing spaces");
|
||||
LOG.debug(BACKINGSPACES_LOG_TEMPLATE, targetSpaces);
|
||||
})
|
||||
@@ -50,7 +50,7 @@ public class DefaultBackingSpaceManagementService implements BackingSpaceManagem
|
||||
LOG.info("Finish deleting backing spaces");
|
||||
LOG.debug(BACKINGSPACES_LOG_TEMPLATE, targetSpaces);
|
||||
})
|
||||
.doOnError(e -> LOG.error(String.format("Error deleting backing spaces. error=%s", e.getMessage()), e));
|
||||
.doOnError((e) -> LOG.error(String.format("Error deleting backing spaces. error=%s", e.getMessage()), e));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2016-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.
|
||||
@@ -49,209 +49,185 @@ public class DeployerClient {
|
||||
}
|
||||
|
||||
public Mono<String> deploy(BackingApplication backingApplication, String serviceInstanceId) {
|
||||
return appDeployer
|
||||
.deploy(DeployApplicationRequest
|
||||
.builder()
|
||||
return this.appDeployer
|
||||
.deploy(DeployApplicationRequest.builder()
|
||||
.name(backingApplication.getName())
|
||||
.path(backingApplication.getPath())
|
||||
.properties(backingApplication.getProperties())
|
||||
.environment(backingApplication.getEnvironment())
|
||||
.services(backingApplication.getServices().stream()
|
||||
.services(backingApplication.getServices()
|
||||
.stream()
|
||||
.map(ServicesSpec::getServiceInstanceName)
|
||||
.collect(Collectors.toList()))
|
||||
.serviceInstanceId(serviceInstanceId)
|
||||
.build())
|
||||
.doOnRequest(l -> {
|
||||
.doOnRequest((l) -> {
|
||||
LOG.info("Deploying application. backingAppName={}", backingApplication.getName());
|
||||
debugLog(backingApplication);
|
||||
})
|
||||
.doOnSuccess(response -> {
|
||||
.doOnSuccess((response) -> {
|
||||
LOG.info("Success deploying application. backingAppName={}", backingApplication.getName());
|
||||
debugLog(response, backingApplication);
|
||||
})
|
||||
.doOnError(e -> {
|
||||
.doOnError((e) -> {
|
||||
LOG.error(String.format("Error deploying application. backingAppName=%s, error=%s",
|
||||
backingApplication.getName(), e.getMessage()), e);
|
||||
backingApplication.getName(), e.getMessage()), e);
|
||||
debugLog(backingApplication);
|
||||
})
|
||||
.map(DeployApplicationResponse::getName);
|
||||
}
|
||||
|
||||
public Mono<String> preUpdate(BackingApplication backingApplication, String serviceInstanceId) {
|
||||
return appDeployer.preUpdate(getUpdateApplicationRequest(backingApplication, serviceInstanceId))
|
||||
.doOnRequest(l -> {
|
||||
return this.appDeployer.preUpdate(getUpdateApplicationRequest(backingApplication, serviceInstanceId))
|
||||
.doOnRequest((l) -> {
|
||||
LOG.info("Pre-updating application. backingAppName={}", backingApplication.getName());
|
||||
debugLog(backingApplication);
|
||||
})
|
||||
.doOnSuccess(response -> {
|
||||
.doOnSuccess((response) -> {
|
||||
LOG.info("Success pre-updating application. backingAppName={}", backingApplication.getName());
|
||||
debugLog(response, backingApplication);
|
||||
})
|
||||
.doOnError(e -> {
|
||||
.doOnError((e) -> {
|
||||
LOG.error(String.format("Error pre-updating application. backingAppName=%s, error=%s",
|
||||
backingApplication.getName(), e.getMessage()), e);
|
||||
backingApplication.getName(), e.getMessage()), e);
|
||||
debugLog(backingApplication);
|
||||
})
|
||||
.map(UpdateApplicationResponse::getName);
|
||||
}
|
||||
|
||||
public Mono<String> update(BackingApplication backingApplication, String serviceInstanceId) {
|
||||
return appDeployer
|
||||
.update(getUpdateApplicationRequest(backingApplication, serviceInstanceId))
|
||||
.doOnRequest(l -> {
|
||||
return this.appDeployer.update(getUpdateApplicationRequest(backingApplication, serviceInstanceId))
|
||||
.doOnRequest((l) -> {
|
||||
LOG.info("Updating application. backingAppName={}", backingApplication.getName());
|
||||
debugLog(backingApplication);
|
||||
})
|
||||
.doOnSuccess(response -> {
|
||||
.doOnSuccess((response) -> {
|
||||
LOG.info("Success updating application. backingAppName={}", backingApplication.getName());
|
||||
debugLog(response, backingApplication);
|
||||
})
|
||||
.doOnError(e -> {
|
||||
.doOnError((e) -> {
|
||||
LOG.error(String.format("Error updating application. backingAppName=%s, error=%s",
|
||||
backingApplication.getName(), e.getMessage()), e);
|
||||
backingApplication.getName(), e.getMessage()), e);
|
||||
debugLog(backingApplication);
|
||||
})
|
||||
.map(UpdateApplicationResponse::getName);
|
||||
}
|
||||
|
||||
public Mono<String> undeploy(BackingApplication backingApplication) {
|
||||
return appDeployer
|
||||
.undeploy(UndeployApplicationRequest
|
||||
.builder()
|
||||
return this.appDeployer
|
||||
.undeploy(UndeployApplicationRequest.builder()
|
||||
.properties(backingApplication.getProperties())
|
||||
.name(backingApplication.getName())
|
||||
.build())
|
||||
.doOnRequest(l -> {
|
||||
.doOnRequest((l) -> {
|
||||
LOG.info("Undeploying application. backingAppName={}", backingApplication.getName());
|
||||
debugLog(backingApplication);
|
||||
})
|
||||
.doOnSuccess(response -> {
|
||||
.doOnSuccess((response) -> {
|
||||
LOG.info("Success undeploying application. backingAppName={}", backingApplication.getName());
|
||||
debugLog(response, backingApplication);
|
||||
})
|
||||
.doOnError(e -> {
|
||||
.doOnError((e) -> {
|
||||
LOG.error(String.format("Error undeploying application. backingAppName=%s, error=%s",
|
||||
backingApplication.getName(), e.getMessage()), e);
|
||||
backingApplication.getName(), e.getMessage()), e);
|
||||
debugLog(backingApplication);
|
||||
})
|
||||
.onErrorReturn(UndeployApplicationResponse.builder()
|
||||
.name(backingApplication.getName())
|
||||
.build())
|
||||
.onErrorReturn(UndeployApplicationResponse.builder().name(backingApplication.getName()).build())
|
||||
.map(UndeployApplicationResponse::getName);
|
||||
}
|
||||
|
||||
public Mono<String> createServiceInstance(BackingService backingService) {
|
||||
return appDeployer
|
||||
.createServiceInstance(
|
||||
CreateServiceInstanceRequest
|
||||
.builder()
|
||||
.serviceInstanceName(backingService.getServiceInstanceName())
|
||||
.name(backingService.getName())
|
||||
.plan(backingService.getPlan())
|
||||
.parameters(backingService.getParameters())
|
||||
.properties(backingService.getProperties())
|
||||
.build())
|
||||
.doOnRequest(l -> {
|
||||
return this.appDeployer
|
||||
.createServiceInstance(CreateServiceInstanceRequest.builder()
|
||||
.serviceInstanceName(backingService.getServiceInstanceName())
|
||||
.name(backingService.getName())
|
||||
.plan(backingService.getPlan())
|
||||
.parameters(backingService.getParameters())
|
||||
.properties(backingService.getProperties())
|
||||
.build())
|
||||
.doOnRequest((l) -> {
|
||||
LOG.info("Creating backing service {}", backingService.getName());
|
||||
debugLog(backingService);
|
||||
})
|
||||
.doOnSuccess(response -> {
|
||||
.doOnSuccess((response) -> {
|
||||
LOG.info("Success creating backing service {}", backingService.getName());
|
||||
debugLog(response, backingService);
|
||||
})
|
||||
.doOnError(e -> {
|
||||
.doOnError((e) -> {
|
||||
LOG.error(String.format("Error creating backing service. backingServiceName=%s, error=%s",
|
||||
backingService.getName(), e.getMessage()), e);
|
||||
backingService.getName(), e.getMessage()), e);
|
||||
debugLog(backingService);
|
||||
})
|
||||
.map(CreateServiceInstanceResponse::getName);
|
||||
}
|
||||
|
||||
public Mono<String> updateServiceInstance(BackingService backingService) {
|
||||
return appDeployer
|
||||
.updateServiceInstance(
|
||||
UpdateServiceInstanceRequest
|
||||
.builder()
|
||||
.serviceInstanceName(backingService.getServiceInstanceName())
|
||||
.parameters(backingService.getParameters())
|
||||
.properties(backingService.getProperties())
|
||||
.rebindOnUpdate(backingService.isRebindOnUpdate())
|
||||
.build())
|
||||
.doOnRequest(l -> {
|
||||
return this.appDeployer
|
||||
.updateServiceInstance(UpdateServiceInstanceRequest.builder()
|
||||
.serviceInstanceName(backingService.getServiceInstanceName())
|
||||
.parameters(backingService.getParameters())
|
||||
.properties(backingService.getProperties())
|
||||
.rebindOnUpdate(backingService.isRebindOnUpdate())
|
||||
.build())
|
||||
.doOnRequest((l) -> {
|
||||
LOG.info("Updating backing service {}", backingService.getName());
|
||||
debugLog(backingService);
|
||||
})
|
||||
.doOnSuccess(response -> {
|
||||
.doOnSuccess((response) -> {
|
||||
LOG.info("Success updating backing service {}", backingService.getName());
|
||||
debugLog(response, backingService);
|
||||
})
|
||||
.doOnError(e -> {
|
||||
.doOnError((e) -> {
|
||||
LOG.error(String.format("Error updating backing service. backingServiceName=%s, error=%s",
|
||||
backingService.getName(), e.getMessage()), e);
|
||||
backingService.getName(), e.getMessage()), e);
|
||||
debugLog(backingService);
|
||||
})
|
||||
.map(UpdateServiceInstanceResponse::getName);
|
||||
}
|
||||
|
||||
public Mono<String> deleteServiceInstance(BackingService backingService) {
|
||||
return appDeployer
|
||||
.deleteServiceInstance(
|
||||
DeleteServiceInstanceRequest
|
||||
.builder()
|
||||
.serviceInstanceName(backingService.getServiceInstanceName())
|
||||
.properties(backingService.getProperties())
|
||||
.build())
|
||||
.doOnRequest(l -> {
|
||||
return this.appDeployer
|
||||
.deleteServiceInstance(DeleteServiceInstanceRequest.builder()
|
||||
.serviceInstanceName(backingService.getServiceInstanceName())
|
||||
.properties(backingService.getProperties())
|
||||
.build())
|
||||
.doOnRequest((l) -> {
|
||||
LOG.info("Deleting backing service {}", backingService.getName());
|
||||
debugLog(backingService);
|
||||
})
|
||||
.doOnSuccess(response -> {
|
||||
.doOnSuccess((response) -> {
|
||||
LOG.info("Success deleting backing service {}", backingService.getName());
|
||||
debugLog(response, backingService);
|
||||
})
|
||||
.doOnError(e -> {
|
||||
.doOnError((e) -> {
|
||||
LOG.error(String.format("Error deleting backing service. backingServiceName=%s, error=%s",
|
||||
backingService.getName(), e.getMessage()), e);
|
||||
backingService.getName(), e.getMessage()), e);
|
||||
debugLog(backingService);
|
||||
})
|
||||
.onErrorReturn(DeleteServiceInstanceResponse.builder()
|
||||
.name(backingService.getServiceInstanceName())
|
||||
.build())
|
||||
.onErrorReturn(
|
||||
DeleteServiceInstanceResponse.builder().name(backingService.getServiceInstanceName()).build())
|
||||
.map(DeleteServiceInstanceResponse::getName);
|
||||
}
|
||||
|
||||
public Mono<String> deleteSpace(String spaceName) {
|
||||
return appDeployer
|
||||
.deleteBackingSpace(
|
||||
DeleteBackingSpaceRequest
|
||||
.builder()
|
||||
.name(spaceName)
|
||||
.build())
|
||||
.doOnRequest(l -> {
|
||||
LOG.info("Deleting backing space {}", spaceName);
|
||||
})
|
||||
.doOnSuccess(response -> {
|
||||
LOG.info("Success deleting backing space {}", spaceName);
|
||||
})
|
||||
.doOnError(e -> {
|
||||
LOG.error(String.format("Error deleting backing space. backingSpaceName=%s, error=%s",
|
||||
spaceName, e.getMessage()), e);
|
||||
})
|
||||
.onErrorReturn(DeleteBackingSpaceResponse.builder()
|
||||
.name(spaceName)
|
||||
.build())
|
||||
return this.appDeployer.deleteBackingSpace(DeleteBackingSpaceRequest.builder().name(spaceName).build())
|
||||
.doOnRequest((l) -> LOG.info("Deleting backing space {}", spaceName))
|
||||
.doOnSuccess((response) -> LOG.info("Success deleting backing space {}", spaceName))
|
||||
.doOnError((e) -> LOG.error(String.format("Error deleting backing space. backingSpaceName=%s, error=%s",
|
||||
spaceName, e.getMessage()), e))
|
||||
.onErrorReturn(DeleteBackingSpaceResponse.builder().name(spaceName).build())
|
||||
.map(DeleteBackingSpaceResponse::getName);
|
||||
}
|
||||
|
||||
private static UpdateApplicationRequest getUpdateApplicationRequest(BackingApplication backingApplication,
|
||||
String serviceInstanceId) {
|
||||
return UpdateApplicationRequest
|
||||
.builder()
|
||||
String serviceInstanceId) {
|
||||
return UpdateApplicationRequest.builder()
|
||||
.name(backingApplication.getName())
|
||||
.path(backingApplication.getPath())
|
||||
.properties(backingApplication.getProperties())
|
||||
.environment(backingApplication.getEnvironment())
|
||||
.services(backingApplication.getServices().stream()
|
||||
.services(backingApplication.getServices()
|
||||
.stream()
|
||||
.map(ServicesSpec::getServiceInstanceName)
|
||||
.collect(Collectors.toList()))
|
||||
.serviceInstanceId(serviceInstanceId)
|
||||
@@ -273,4 +249,5 @@ public class DeployerClient {
|
||||
private static void debugLog(Object response, BackingService backingService) {
|
||||
LOG.debug("response={}, backingService={}", response, backingService);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -36,7 +36,7 @@ public class ParametersTransformerSpec {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
@@ -44,7 +44,7 @@ public class ParametersTransformerSpec {
|
||||
}
|
||||
|
||||
public Map<String, Object> getArgs() {
|
||||
return args;
|
||||
return this.args;
|
||||
}
|
||||
|
||||
public void setArgs(Map<String, Object> args) {
|
||||
@@ -65,8 +65,7 @@ public class ParametersTransformerSpec {
|
||||
}
|
||||
|
||||
public ParametersTransformerSpecBuilder spec(ParametersTransformerSpec spec) {
|
||||
return this.name(spec.getName())
|
||||
.args(spec.getArgs());
|
||||
return this.name(spec.getName()).args(spec.getArgs());
|
||||
}
|
||||
|
||||
public ParametersTransformerSpecBuilder name(String name) {
|
||||
@@ -89,7 +88,7 @@ public class ParametersTransformerSpec {
|
||||
}
|
||||
|
||||
public ParametersTransformerSpec build() {
|
||||
return new ParametersTransformerSpec(name, args);
|
||||
return new ParametersTransformerSpec(this.name, this.args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -30,7 +30,7 @@ public class ServicesSpec {
|
||||
}
|
||||
|
||||
public String getServiceInstanceName() {
|
||||
return serviceInstanceName;
|
||||
return this.serviceInstanceName;
|
||||
}
|
||||
|
||||
public void setServiceInstanceName(String serviceInstanceName) {
|
||||
@@ -50,19 +50,17 @@ public class ServicesSpec {
|
||||
return false;
|
||||
}
|
||||
ServicesSpec that = (ServicesSpec) o;
|
||||
return Objects.equals(serviceInstanceName, that.serviceInstanceName);
|
||||
return Objects.equals(this.serviceInstanceName, that.serviceInstanceName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(serviceInstanceName);
|
||||
return Objects.hash(this.serviceInstanceName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServicesSpec{" +
|
||||
"serviceInstanceName='" + serviceInstanceName + '\'' +
|
||||
'}';
|
||||
return "ServicesSpec{" + "serviceInstanceName='" + this.serviceInstanceName + '\'' + '}';
|
||||
}
|
||||
|
||||
public static final class ServicesSpecBuilder {
|
||||
@@ -82,7 +80,7 @@ public class ServicesSpec {
|
||||
}
|
||||
|
||||
public ServicesSpec build() {
|
||||
return new ServicesSpec(serviceInstanceName);
|
||||
return new ServicesSpec(this.serviceInstanceName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -30,14 +30,13 @@ public class TargetSpec {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public static TargetSpecBuilder builder() {
|
||||
return new TargetSpecBuilder();
|
||||
}
|
||||
@@ -51,12 +50,12 @@ public class TargetSpec {
|
||||
return false;
|
||||
}
|
||||
TargetSpec that = (TargetSpec) o;
|
||||
return Objects.equals(name, that.name);
|
||||
return Objects.equals(this.name, that.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name);
|
||||
return Objects.hash(this.name);
|
||||
}
|
||||
|
||||
public static final class TargetSpecBuilder {
|
||||
@@ -70,9 +69,11 @@ public class TargetSpec {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TargetSpec build() {
|
||||
return new TargetSpec(name);
|
||||
return new TargetSpec(this.name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016-2024 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* App Broker Deployer.
|
||||
*/
|
||||
package org.springframework.cloud.appbroker.deployer;
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -28,7 +28,7 @@ public class ExtensionLocator<T> {
|
||||
private final Map<String, ExtensionFactory<T, ?>> factoriesByName = new HashMap<>();
|
||||
|
||||
public ExtensionLocator(List<? extends ExtensionFactory<T, ?>> factories) {
|
||||
factories.forEach(extension -> this.factoriesByName.put(extension.getName(), extension));
|
||||
factories.forEach((extension) -> this.factoriesByName.put(extension.getName(), extension));
|
||||
}
|
||||
|
||||
public T getByName(String name) {
|
||||
@@ -41,17 +41,16 @@ public class ExtensionLocator<T> {
|
||||
}
|
||||
|
||||
private ExtensionFactory<T, ?> getFactoryByName(String name) {
|
||||
if (factoriesByName.containsKey(name)) {
|
||||
return factoriesByName.get(name);
|
||||
if (this.factoriesByName.containsKey(name)) {
|
||||
return this.factoriesByName.get(name);
|
||||
}
|
||||
else {
|
||||
throw new ServiceBrokerException("Unknown extension " + name + ". " +
|
||||
"Registered extensions are " + factoriesByName.keySet());
|
||||
throw new ServiceBrokerException(
|
||||
"Unknown extension " + name + ". " + "Registered extensions are " + this.factoriesByName.keySet());
|
||||
}
|
||||
}
|
||||
|
||||
private T getExtensionFromFactory(ExtensionFactory<T, ?> factory,
|
||||
Map<String, Object> args) {
|
||||
private T getExtensionFromFactory(ExtensionFactory<T, ?> factory, Map<String, Object> args) {
|
||||
return factory.createWithConfig(args);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016-2024 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* App Broker Extensions.
|
||||
*/
|
||||
package org.springframework.cloud.appbroker.extensions;
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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,30 +32,26 @@ public class BackingApplicationsParametersTransformationService {
|
||||
private final ExtensionLocator<ParametersTransformer<BackingApplication>> locator;
|
||||
|
||||
public BackingApplicationsParametersTransformationService(
|
||||
List<ParametersTransformerFactory<BackingApplication, ?>> factories) {
|
||||
locator = new ExtensionLocator<>(factories);
|
||||
List<ParametersTransformerFactory<BackingApplication, ?>> factories) {
|
||||
this.locator = new ExtensionLocator<>(factories);
|
||||
}
|
||||
|
||||
public Mono<List<BackingApplication>> transformParameters(List<BackingApplication> backingApplications,
|
||||
Map<String, Object> parameters) {
|
||||
return Flux.fromIterable(backingApplications)
|
||||
.flatMap(backingApplication -> {
|
||||
List<ParametersTransformerSpec> specs = getTransformerSpecsForApplication(backingApplication);
|
||||
Map<String, Object> parameters) {
|
||||
return Flux.fromIterable(backingApplications).flatMap((backingApplication) -> {
|
||||
List<ParametersTransformerSpec> specs = getTransformerSpecsForApplication(backingApplication);
|
||||
|
||||
return Flux.fromIterable(specs)
|
||||
.flatMap(spec -> {
|
||||
ParametersTransformer<BackingApplication> transformer = locator
|
||||
.getByName(spec.getName(), spec.getArgs());
|
||||
return transformer.transform(backingApplication, parameters);
|
||||
})
|
||||
.then(Mono.just(backingApplication));
|
||||
})
|
||||
.collectList();
|
||||
return Flux.fromIterable(specs).flatMap((spec) -> {
|
||||
ParametersTransformer<BackingApplication> transformer = this.locator.getByName(spec.getName(),
|
||||
spec.getArgs());
|
||||
return transformer.transform(backingApplication, parameters);
|
||||
}).then(Mono.just(backingApplication));
|
||||
}).collectList();
|
||||
}
|
||||
|
||||
private List<ParametersTransformerSpec> getTransformerSpecsForApplication(BackingApplication backingApplication) {
|
||||
return backingApplication.getParametersTransformers() == null ? Collections.emptyList() :
|
||||
backingApplication.getParametersTransformers();
|
||||
return (backingApplication.getParametersTransformers() == null) ? Collections.emptyList()
|
||||
: backingApplication.getParametersTransformers();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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,31 +32,26 @@ public class BackingServicesParametersTransformationService {
|
||||
private final ExtensionLocator<ParametersTransformer<BackingService>> locator;
|
||||
|
||||
public BackingServicesParametersTransformationService(
|
||||
List<ParametersTransformerFactory<BackingService, ?>> factories) {
|
||||
locator = new ExtensionLocator<>(factories);
|
||||
List<ParametersTransformerFactory<BackingService, ?>> factories) {
|
||||
this.locator = new ExtensionLocator<>(factories);
|
||||
}
|
||||
|
||||
public Mono<List<BackingService>> transformParameters(List<BackingService> backingServices,
|
||||
Map<String, Object> parameters) {
|
||||
return Flux.fromIterable(backingServices)
|
||||
.flatMap(backingService -> {
|
||||
List<ParametersTransformerSpec> specs = getTransformerSpecsForService(backingService);
|
||||
Map<String, Object> parameters) {
|
||||
return Flux.fromIterable(backingServices).flatMap((backingService) -> {
|
||||
List<ParametersTransformerSpec> specs = getTransformerSpecsForService(backingService);
|
||||
|
||||
return Flux.fromIterable(specs)
|
||||
.flatMap(spec -> {
|
||||
ParametersTransformer<BackingService> transformer = locator
|
||||
.getByName(spec.getName(), spec.getArgs());
|
||||
return transformer.transform(backingService, parameters);
|
||||
})
|
||||
.then(Mono.just(backingService));
|
||||
})
|
||||
.collectList();
|
||||
return Flux.fromIterable(specs).flatMap((spec) -> {
|
||||
ParametersTransformer<BackingService> transformer = this.locator.getByName(spec.getName(),
|
||||
spec.getArgs());
|
||||
return transformer.transform(backingService, parameters);
|
||||
}).then(Mono.just(backingService));
|
||||
}).collectList();
|
||||
}
|
||||
|
||||
private List<ParametersTransformerSpec> getTransformerSpecsForService(BackingService backingService) {
|
||||
return backingService.getParametersTransformers() == null
|
||||
? Collections.emptyList()
|
||||
: backingService.getParametersTransformers();
|
||||
return (backingService.getParametersTransformers() == null) ? Collections.emptyList()
|
||||
: backingService.getParametersTransformers();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -29,7 +29,7 @@ import reactor.util.Loggers;
|
||||
import org.springframework.cloud.appbroker.deployer.BackingApplication;
|
||||
|
||||
public class EnvironmentMappingParametersTransformerFactory extends
|
||||
ParametersTransformerFactory<BackingApplication, EnvironmentMappingParametersTransformerFactory.Config> {
|
||||
ParametersTransformerFactory<BackingApplication, EnvironmentMappingParametersTransformerFactory.Config> {
|
||||
|
||||
private static final Logger LOG = Loggers.getLogger(EnvironmentMappingParametersTransformerFactory.class);
|
||||
|
||||
@@ -44,30 +44,26 @@ public class EnvironmentMappingParametersTransformerFactory extends
|
||||
return (backingType, parameters) -> transform(backingType, parameters, config.getIncludes());
|
||||
}
|
||||
|
||||
private Mono<BackingApplication> transform(BackingApplication backingApplication,
|
||||
Map<String, Object> parameters,
|
||||
List<String> include) {
|
||||
private Mono<BackingApplication> transform(BackingApplication backingApplication, Map<String, Object> parameters,
|
||||
List<String> include) {
|
||||
if (parameters != null) {
|
||||
parameters
|
||||
.keySet().stream()
|
||||
.filter(include::contains)
|
||||
.forEach(key -> {
|
||||
Object value = parameters.get(key);
|
||||
String valueString;
|
||||
if (value instanceof String) {
|
||||
parameters.keySet().stream().filter(include::contains).forEach((key) -> {
|
||||
Object value = parameters.get(key);
|
||||
String valueString;
|
||||
if (value instanceof String) {
|
||||
valueString = value.toString();
|
||||
}
|
||||
else {
|
||||
try {
|
||||
valueString = OBJECT_MAPPER.writeValueAsString(value);
|
||||
}
|
||||
catch (JsonProcessingException ex) {
|
||||
LOG.error("Failed to write object as JSON String", ex);
|
||||
valueString = value.toString();
|
||||
}
|
||||
else {
|
||||
try {
|
||||
valueString = OBJECT_MAPPER.writeValueAsString(value);
|
||||
}
|
||||
catch (JsonProcessingException e) {
|
||||
LOG.error("Failed to write object as JSON String", e);
|
||||
valueString = value.toString();
|
||||
}
|
||||
}
|
||||
backingApplication.addEnvironment(key, valueString);
|
||||
});
|
||||
}
|
||||
backingApplication.addEnvironment(key, valueString);
|
||||
});
|
||||
}
|
||||
|
||||
return Mono.just(backingApplication);
|
||||
@@ -79,7 +75,7 @@ public class EnvironmentMappingParametersTransformerFactory extends
|
||||
private String include;
|
||||
|
||||
public List<String> getIncludes() {
|
||||
return Arrays.asList(include.split(","));
|
||||
return Arrays.asList(this.include.split(","));
|
||||
}
|
||||
|
||||
public void setInclude(String include) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -24,8 +24,8 @@ import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.cloud.appbroker.deployer.BackingService;
|
||||
|
||||
public class ParameterMappingParametersTransformerFactory extends
|
||||
ParametersTransformerFactory<BackingService, ParameterMappingParametersTransformerFactory.Config> {
|
||||
public class ParameterMappingParametersTransformerFactory
|
||||
extends ParametersTransformerFactory<BackingService, ParameterMappingParametersTransformerFactory.Config> {
|
||||
|
||||
public ParameterMappingParametersTransformerFactory() {
|
||||
super(Config.class);
|
||||
@@ -36,13 +36,13 @@ public class ParameterMappingParametersTransformerFactory extends
|
||||
return (backingType, parameters) -> transform(backingType, parameters, config.getIncludes());
|
||||
}
|
||||
|
||||
private Mono<BackingService> transform(BackingService backingService,
|
||||
Map<String, Object> parameters,
|
||||
List<String> include) {
|
||||
private Mono<BackingService> transform(BackingService backingService, Map<String, Object> parameters,
|
||||
List<String> include) {
|
||||
if (parameters != null) {
|
||||
parameters.keySet().stream()
|
||||
parameters.keySet()
|
||||
.stream()
|
||||
.filter(include::contains)
|
||||
.forEach(key -> backingService.addParameter(key, parameters.get(key)));
|
||||
.forEach((key) -> backingService.addParameter(key, parameters.get(key)));
|
||||
}
|
||||
|
||||
return Mono.just(backingService);
|
||||
@@ -54,7 +54,7 @@ public class ParameterMappingParametersTransformerFactory extends
|
||||
private String include;
|
||||
|
||||
public List<String> getIncludes() {
|
||||
return Arrays.asList(include.split(","));
|
||||
return Arrays.asList(this.include.split(","));
|
||||
}
|
||||
|
||||
public void setInclude(String include) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -24,8 +24,8 @@ import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.cloud.appbroker.deployer.BackingApplication;
|
||||
|
||||
public class PropertyMappingParametersTransformerFactory extends
|
||||
ParametersTransformerFactory<BackingApplication, PropertyMappingParametersTransformerFactory.Config> {
|
||||
public class PropertyMappingParametersTransformerFactory
|
||||
extends ParametersTransformerFactory<BackingApplication, PropertyMappingParametersTransformerFactory.Config> {
|
||||
|
||||
public PropertyMappingParametersTransformerFactory() {
|
||||
super(Config.class);
|
||||
@@ -36,13 +36,13 @@ public class PropertyMappingParametersTransformerFactory extends
|
||||
return (backingApplication, parameters) -> transform(backingApplication, parameters, config.getIncludes());
|
||||
}
|
||||
|
||||
private Mono<BackingApplication> transform(BackingApplication backingApplication,
|
||||
Map<String, Object> parameters,
|
||||
List<String> include) {
|
||||
private Mono<BackingApplication> transform(BackingApplication backingApplication, Map<String, Object> parameters,
|
||||
List<String> include) {
|
||||
if (parameters != null) {
|
||||
parameters.keySet().stream()
|
||||
parameters.keySet()
|
||||
.stream()
|
||||
.filter(include::contains)
|
||||
.forEach(key -> backingApplication.addProperty(key, parameters.get(key).toString()));
|
||||
.forEach((key) -> backingApplication.addProperty(key, parameters.get(key).toString()));
|
||||
}
|
||||
return Mono.just(backingApplication);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public class PropertyMappingParametersTransformerFactory extends
|
||||
private String include;
|
||||
|
||||
public List<String> getIncludes() {
|
||||
return Arrays.asList(include.split(","));
|
||||
return Arrays.asList(this.include.split(","));
|
||||
}
|
||||
|
||||
public void setInclude(String include) {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016-2024 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* App Broker Extensions Parameters.
|
||||
*/
|
||||
package org.springframework.cloud.appbroker.extensions.parameters;
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -49,9 +49,10 @@ public final class ConfigurationBeanUtils {
|
||||
beanUtils.getPropertyUtils().addBeanIntrospector(SuppressPropertiesBeanIntrospector.SUPPRESS_CLASS);
|
||||
beanUtils.copyProperties(target, properties);
|
||||
}
|
||||
catch (IllegalAccessException | InvocationTargetException e) {
|
||||
throw new IllegalArgumentException("Failed to populate target of type " + targetObject.getClass()
|
||||
+ " with properties " + properties, e);
|
||||
catch (IllegalAccessException | InvocationTargetException ex) {
|
||||
throw new IllegalArgumentException(
|
||||
"Failed to populate target of type " + targetObject.getClass() + " with properties " + properties,
|
||||
ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,8 +63,8 @@ public final class ConfigurationBeanUtils {
|
||||
return (T) ((Advised) candidate).getTargetSource().getTarget();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException("Failed to unwrap proxied object", e);
|
||||
catch (Exception ex) {
|
||||
throw new IllegalStateException("Failed to unwrap proxied object", ex);
|
||||
}
|
||||
return (T) candidate;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.appbroker.extensions.support;
|
||||
|
||||
import java.beans.IntrospectionException;
|
||||
@@ -28,12 +29,14 @@ import reactor.util.Logger;
|
||||
import reactor.util.Loggers;
|
||||
|
||||
/**
|
||||
* An implementation of the {@link BeanIntrospector} interface that provides property descriptors following the
|
||||
* kebab-case convention.
|
||||
* An implementation of the {@link BeanIntrospector} interface that provides property
|
||||
* descriptors following the kebab-case convention.
|
||||
* <p>
|
||||
* This implementation is intended to collaborate with a {@link DefaultBeanIntrospector} object. Best results are
|
||||
* achieved by adding this instance as custom {@link BeanIntrospector} after the {@link DefaultBeanIntrospector}
|
||||
* object.
|
||||
* This implementation is intended to collaborate with a {@link DefaultBeanIntrospector}
|
||||
* object. Best results are achieved by adding this instance as custom
|
||||
* {@link BeanIntrospector} after the {@link DefaultBeanIntrospector} object.
|
||||
*
|
||||
* @author Scott Frederick
|
||||
*/
|
||||
public class KebabCasePropertyBeanIntrospector implements BeanIntrospector {
|
||||
|
||||
@@ -42,10 +45,9 @@ public class KebabCasePropertyBeanIntrospector implements BeanIntrospector {
|
||||
private static final String WRITE_METHOD_PREFIX = "set";
|
||||
|
||||
/**
|
||||
* Performs introspection. This method scans the current class's methods for property write methods add adds a
|
||||
* property descriptor using the kebab-case naming convention to match each property descriptor that uses the
|
||||
* camel-case Java Bean convention.
|
||||
*
|
||||
* Performs introspection. This method scans the current class's methods for property
|
||||
* write methods add adds a property descriptor using the kebab-case naming convention
|
||||
* to match each property descriptor that uses the camel-case Java Bean convention.
|
||||
* @param context the introspection context
|
||||
*/
|
||||
@Override
|
||||
@@ -59,10 +61,10 @@ public class KebabCasePropertyBeanIntrospector implements BeanIntrospector {
|
||||
context.addPropertyDescriptor(createPropertyDescriptor(m));
|
||||
}
|
||||
}
|
||||
catch (final IntrospectionException e) {
|
||||
catch (final IntrospectionException ex) {
|
||||
if (LOG.isErrorEnabled()) {
|
||||
LOG.error(String.format("Error when creating PropertyDescriptor for method '%s'. This " +
|
||||
"property will be ignored. %s", m), e);
|
||||
LOG.error(String.format("Error when creating PropertyDescriptor for method '%s'. This "
|
||||
+ "property will be ignored. %s", m), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,20 +73,17 @@ public class KebabCasePropertyBeanIntrospector implements BeanIntrospector {
|
||||
|
||||
/**
|
||||
* Derives the camel-case name of a property from the given set method.
|
||||
*
|
||||
* @param m the method
|
||||
* @return the corresponding property name
|
||||
*/
|
||||
private String camelCasePropertyName(final Method m) {
|
||||
final String methodName = m.getName().substring(WRITE_METHOD_PREFIX.length());
|
||||
return methodName.length() > 1 ?
|
||||
Introspector.decapitalize(methodName) :
|
||||
methodName.toLowerCase(Locale.ENGLISH);
|
||||
return (methodName.length() > 1) ? Introspector.decapitalize(methodName)
|
||||
: methodName.toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Derives the kebab-case name of a property from the given set method.
|
||||
*
|
||||
* @param m the method
|
||||
* @return the corresponding property name
|
||||
*/
|
||||
@@ -106,7 +105,6 @@ public class KebabCasePropertyBeanIntrospector implements BeanIntrospector {
|
||||
|
||||
/**
|
||||
* Creates a property descriptor for a property.
|
||||
*
|
||||
* @param m the set method for the property
|
||||
* @return the descriptor
|
||||
* @throws IntrospectionException if an error occurs
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016-2024 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* App Broker Extensions Support.
|
||||
*/
|
||||
package org.springframework.cloud.appbroker.extensions.support;
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -33,11 +33,11 @@ public class ArtifactDetails {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Map<String, String> getProperties() {
|
||||
return properties;
|
||||
return this.properties;
|
||||
}
|
||||
|
||||
public static ArtifactDetailsBuilder builder() {
|
||||
@@ -66,7 +66,7 @@ public class ArtifactDetails {
|
||||
}
|
||||
|
||||
public ArtifactDetails build() {
|
||||
return new ArtifactDetails(name, properties);
|
||||
return new ArtifactDetails(this.name, this.properties);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -54,6 +54,7 @@ public class ServiceInstanceGuidSuffix extends TargetFactory<ServiceInstanceGuid
|
||||
}
|
||||
|
||||
public static class Config {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -35,13 +35,11 @@ public class SpacePerServiceInstance extends TargetFactory<SpacePerServiceInstan
|
||||
properties.put(DeploymentProperties.HOST_PROPERTY_KEY, name + "-" + serviceInstanceId);
|
||||
properties.put(DeploymentProperties.TARGET_PROPERTY_KEY, serviceInstanceId);
|
||||
|
||||
return ArtifactDetails.builder()
|
||||
.name(name)
|
||||
.properties(properties)
|
||||
.build();
|
||||
return ArtifactDetails.builder().name(name).properties(properties).build();
|
||||
}
|
||||
|
||||
public static class Config {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -33,49 +33,44 @@ public class TargetService {
|
||||
private final ExtensionLocator<Target> locator;
|
||||
|
||||
public TargetService(List<TargetFactory<?>> factories) {
|
||||
locator = new ExtensionLocator<>(factories);
|
||||
this.locator = new ExtensionLocator<>(factories);
|
||||
}
|
||||
|
||||
public Mono<List<BackingApplication>> addToBackingApplications(List<BackingApplication> backingApplications,
|
||||
TargetSpec targetSpec, String serviceInstanceId) {
|
||||
return Flux.fromIterable(backingApplications)
|
||||
.flatMap(backingApplication -> {
|
||||
if (targetSpec != null) {
|
||||
ArtifactDetails appDetails = getArtifactDetails(targetSpec, serviceInstanceId,
|
||||
TargetSpec targetSpec, String serviceInstanceId) {
|
||||
return Flux.fromIterable(backingApplications).flatMap((backingApplication) -> {
|
||||
if (targetSpec != null) {
|
||||
ArtifactDetails appDetails = getArtifactDetails(targetSpec, serviceInstanceId,
|
||||
backingApplication.getName(), backingApplication.getProperties());
|
||||
backingApplication.setName(appDetails.getName());
|
||||
backingApplication.setProperties(appDetails.getProperties());
|
||||
backingApplication.setName(appDetails.getName());
|
||||
backingApplication.setProperties(appDetails.getProperties());
|
||||
|
||||
backingApplication.getServices().forEach(servicesSpec -> {
|
||||
ArtifactDetails serviceDetails = getArtifactDetails(targetSpec, serviceInstanceId,
|
||||
servicesSpec.getServiceInstanceName(), new HashMap<>());
|
||||
servicesSpec.setServiceInstanceName(serviceDetails.getName());
|
||||
});
|
||||
}
|
||||
return Mono.just(backingApplication);
|
||||
})
|
||||
.collectList();
|
||||
}
|
||||
|
||||
public Mono<List<BackingService>> addToBackingServices(List<BackingService> backingServices,
|
||||
TargetSpec targetSpec,
|
||||
String serviceInstanceId) {
|
||||
return Flux.fromIterable(backingServices)
|
||||
.flatMap(backingService -> {
|
||||
if (targetSpec != null) {
|
||||
backingApplication.getServices().forEach((servicesSpec) -> {
|
||||
ArtifactDetails serviceDetails = getArtifactDetails(targetSpec, serviceInstanceId,
|
||||
backingService.getServiceInstanceName(), backingService.getProperties());
|
||||
backingService.setServiceInstanceName(serviceDetails.getName());
|
||||
backingService.setProperties(serviceDetails.getProperties());
|
||||
}
|
||||
return Mono.just(backingService);
|
||||
})
|
||||
.collectList();
|
||||
servicesSpec.getServiceInstanceName(), new HashMap<>());
|
||||
servicesSpec.setServiceInstanceName(serviceDetails.getName());
|
||||
});
|
||||
}
|
||||
return Mono.just(backingApplication);
|
||||
}).collectList();
|
||||
}
|
||||
|
||||
private ArtifactDetails getArtifactDetails(TargetSpec targetSpec, String serviceInstanceId,
|
||||
String name, Map<String, String> properties) {
|
||||
Target target = locator.getByName(targetSpec.getName());
|
||||
public Mono<List<BackingService>> addToBackingServices(List<BackingService> backingServices, TargetSpec targetSpec,
|
||||
String serviceInstanceId) {
|
||||
return Flux.fromIterable(backingServices).flatMap((backingService) -> {
|
||||
if (targetSpec != null) {
|
||||
ArtifactDetails serviceDetails = getArtifactDetails(targetSpec, serviceInstanceId,
|
||||
backingService.getServiceInstanceName(), backingService.getProperties());
|
||||
backingService.setServiceInstanceName(serviceDetails.getName());
|
||||
backingService.setProperties(serviceDetails.getProperties());
|
||||
}
|
||||
return Mono.just(backingService);
|
||||
}).collectList();
|
||||
}
|
||||
|
||||
private ArtifactDetails getArtifactDetails(TargetSpec targetSpec, String serviceInstanceId, String name,
|
||||
Map<String, String> properties) {
|
||||
Target target = this.locator.getByName(targetSpec.getName());
|
||||
return target.apply(properties, name, serviceInstanceId);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016-2024 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* App Broker Extensions Targets.
|
||||
*/
|
||||
package org.springframework.cloud.appbroker.extensions.targets;
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors
|
||||
* Copyright 2016-2024 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -49,7 +49,7 @@ public class BackingAppManagementService {
|
||||
private final TargetService targetService;
|
||||
|
||||
public BackingAppManagementService(ManagementClient managementClient, AppDeployer appDeployer,
|
||||
BrokeredServices brokeredServices, TargetService targetService) {
|
||||
BrokeredServices brokeredServices, TargetService targetService) {
|
||||
this.managementClient = managementClient;
|
||||
this.appDeployer = appDeployer;
|
||||
this.brokeredServices = brokeredServices;
|
||||
@@ -57,14 +57,15 @@ public class BackingAppManagementService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that fetches service name and plan name from Cloud Foundry Service Instances API (CF API) and
|
||||
* invokes {@code stop(serviceInstanceId, serviceName, planName)}.
|
||||
* Helper method that fetches service name and plan name from Cloud Foundry Service
|
||||
* Instances API (CF API) and invokes
|
||||
* {@code stop(serviceInstanceId, serviceName, planName)}.
|
||||
*
|
||||
* Because this method will try to fetch user-created service instance, UAA client used by the broker has to be a
|
||||
* space developer of the space containing the service instance, or has to have {@code cloud_controller.admin}
|
||||
* authority. If you want to avoid CF API call, use
|
||||
* Because this method will try to fetch user-created service instance, UAA client
|
||||
* used by the broker has to be a space developer of the space containing the service
|
||||
* instance, or has to have {@code cloud_controller.admin} authority. If you want to
|
||||
* avoid CF API call, use
|
||||
* {@link BackingAppManagementService#stop(String, String, String)} method.
|
||||
*
|
||||
* @param serviceInstanceId target service instance id
|
||||
* @return completes when the operation is completed
|
||||
*/
|
||||
@@ -72,9 +73,8 @@ public class BackingAppManagementService {
|
||||
return fetchServiceDetailsAndInvoke(serviceInstanceId, this::stop);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Stops the backing applications for the service instance with the given id
|
||||
* Stops the backing applications for the service instance with the given id.
|
||||
* @param serviceInstanceId target service instance id
|
||||
* @param serviceName service name
|
||||
* @param planName plan name
|
||||
@@ -82,11 +82,11 @@ public class BackingAppManagementService {
|
||||
*/
|
||||
public Mono<Void> stop(String serviceInstanceId, String serviceName, String planName) {
|
||||
return getBackingApplicationsForService(serviceInstanceId, serviceName, planName)
|
||||
.flatMapMany(backingApps -> Flux.fromIterable(backingApps)
|
||||
.flatMapMany((backingApps) -> Flux.fromIterable(backingApps)
|
||||
.parallel()
|
||||
.runOn(Schedulers.parallel())
|
||||
.flatMap(managementClient::stop)
|
||||
.doOnRequest(l -> {
|
||||
.flatMap(this.managementClient::stop)
|
||||
.doOnRequest((l) -> {
|
||||
LOG.info("Stopping applications");
|
||||
LOG.debug(BACKINGAPPS_LOG_TEMPLATE, backingApps);
|
||||
})
|
||||
@@ -94,7 +94,7 @@ public class BackingAppManagementService {
|
||||
LOG.info("Finish stopping applications");
|
||||
LOG.debug(BACKINGAPPS_LOG_TEMPLATE, backingApps);
|
||||
})
|
||||
.doOnError(e -> {
|
||||
.doOnError((e) -> {
|
||||
LOG.error(String.format("Error stopping applications. error=%s", e.getMessage()), e);
|
||||
LOG.debug(BACKINGAPPS_LOG_TEMPLATE, backingApps);
|
||||
}))
|
||||
@@ -102,14 +102,15 @@ public class BackingAppManagementService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that fetches service name and plan name from Cloud Foundry Service Instances API (CF API) and
|
||||
* invokes {@code start(serviceInstanceId, serviceName, planName)}.
|
||||
* Helper method that fetches service name and plan name from Cloud Foundry Service
|
||||
* Instances API (CF API) and invokes
|
||||
* {@code start(serviceInstanceId, serviceName, planName)}.
|
||||
*
|
||||
* Because this method will try to fetch user-created service instance, UAA client used by the broker has to be a
|
||||
* space developer of the space containing the service instance, or has to have {@code cloud_controller.admin}
|
||||
* authority. If you want to avoid CF API call, use
|
||||
* Because this method will try to fetch user-created service instance, UAA client
|
||||
* used by the broker has to be a space developer of the space containing the service
|
||||
* instance, or has to have {@code cloud_controller.admin} authority. If you want to
|
||||
* avoid CF API call, use
|
||||
* {@link BackingAppManagementService#start(String, String, String)} method.
|
||||
*
|
||||
* @param serviceInstanceId target service instance id
|
||||
* @return completes when the operation is completed
|
||||
*/
|
||||
@@ -118,7 +119,7 @@ public class BackingAppManagementService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the backing applications for the service instance with the given id
|
||||
* Starts the backing applications for the service instance with the given id.
|
||||
* @param serviceInstanceId target service instance id
|
||||
* @param serviceName service name
|
||||
* @param planName plan name
|
||||
@@ -126,11 +127,11 @@ public class BackingAppManagementService {
|
||||
*/
|
||||
public Mono<Void> start(String serviceInstanceId, String serviceName, String planName) {
|
||||
return getBackingApplicationsForService(serviceInstanceId, serviceName, planName)
|
||||
.flatMapMany(backingApps -> Flux.fromIterable(backingApps)
|
||||
.flatMapMany((backingApps) -> Flux.fromIterable(backingApps)
|
||||
.parallel()
|
||||
.runOn(Schedulers.parallel())
|
||||
.flatMap(managementClient::start)
|
||||
.doOnRequest(l -> {
|
||||
.flatMap(this.managementClient::start)
|
||||
.doOnRequest((l) -> {
|
||||
LOG.info("Starting applications");
|
||||
LOG.debug(BACKINGAPPS_LOG_TEMPLATE, backingApps);
|
||||
})
|
||||
@@ -138,7 +139,7 @@ public class BackingAppManagementService {
|
||||
LOG.info("Finish starting applications");
|
||||
LOG.debug(BACKINGAPPS_LOG_TEMPLATE, backingApps);
|
||||
})
|
||||
.doOnError(e -> {
|
||||
.doOnError((e) -> {
|
||||
LOG.error(String.format("Error starting applications. error=%s", e.getMessage()), e);
|
||||
LOG.debug(BACKINGAPPS_LOG_TEMPLATE, backingApps);
|
||||
}))
|
||||
@@ -146,14 +147,15 @@ public class BackingAppManagementService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that fetches service name and plan name from Cloud Foundry Service Instances API (CF API) and
|
||||
* invokes {@code restart(serviceInstanceId, serviceName, planName)}.
|
||||
* Helper method that fetches service name and plan name from Cloud Foundry Service
|
||||
* Instances API (CF API) and invokes
|
||||
* {@code restart(serviceInstanceId, serviceName, planName)}.
|
||||
*
|
||||
* Because this method will try to fetch user-created service instance, UAA client used by the broker has to be a
|
||||
* space developer of the space containing the service instance, or has to have {@code cloud_controller.admin}
|
||||
* authority. If you want to avoid CF API call, use
|
||||
* Because this method will try to fetch user-created service instance, UAA client
|
||||
* used by the broker has to be a space developer of the space containing the service
|
||||
* instance, or has to have {@code cloud_controller.admin} authority. If you want to
|
||||
* avoid CF API call, use
|
||||
* {@link BackingAppManagementService#restart(String, String, String)} method.
|
||||
*
|
||||
* @param serviceInstanceId target service instance id
|
||||
* @return completes when the operation is completed
|
||||
*/
|
||||
@@ -162,7 +164,7 @@ public class BackingAppManagementService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Restarts the backing applications for the service instance with the given id
|
||||
* Restarts the backing applications for the service instance with the given id.
|
||||
* @param serviceInstanceId target service instance id
|
||||
* @param serviceName service name
|
||||
* @param planName plan name
|
||||
@@ -170,11 +172,11 @@ public class BackingAppManagementService {
|
||||
*/
|
||||
public Mono<Void> restart(String serviceInstanceId, String serviceName, String planName) {
|
||||
return getBackingApplicationsForService(serviceInstanceId, serviceName, planName)
|
||||
.flatMapMany(backingApps -> Flux.fromIterable(backingApps)
|
||||
.flatMapMany((backingApps) -> Flux.fromIterable(backingApps)
|
||||
.parallel()
|
||||
.runOn(Schedulers.parallel())
|
||||
.flatMap(managementClient::restart)
|
||||
.doOnRequest(l -> {
|
||||
.flatMap(this.managementClient::restart)
|
||||
.doOnRequest((l) -> {
|
||||
LOG.info("Restarting applications");
|
||||
LOG.debug(BACKINGAPPS_LOG_TEMPLATE, backingApps);
|
||||
})
|
||||
@@ -182,7 +184,7 @@ public class BackingAppManagementService {
|
||||
LOG.info("Finish restarting applications");
|
||||
LOG.debug(BACKINGAPPS_LOG_TEMPLATE, backingApps);
|
||||
})
|
||||
.doOnError(e -> {
|
||||
.doOnError((e) -> {
|
||||
LOG.error(String.format("Error restarting applications. error=%s", e.getMessage()), e);
|
||||
LOG.debug(BACKINGAPPS_LOG_TEMPLATE, backingApps);
|
||||
}))
|
||||
@@ -190,14 +192,15 @@ public class BackingAppManagementService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that fetches service name and plan name from Cloud Foundry Service Instances API (CF API) and
|
||||
* invokes {@code restage(serviceInstanceId, serviceName, planName)}.
|
||||
* Helper method that fetches service name and plan name from Cloud Foundry Service
|
||||
* Instances API (CF API) and invokes
|
||||
* {@code restage(serviceInstanceId, serviceName, planName)}.
|
||||
*
|
||||
* Because this method will try to fetch user-created service instance, UAA client used by the broker has to be a
|
||||
* space developer of the space containing the service instance, or has to have {@code cloud_controller.admin}
|
||||
* authority. If you want to avoid CF API call, use
|
||||
* Because this method will try to fetch user-created service instance, UAA client
|
||||
* used by the broker has to be a space developer of the space containing the service
|
||||
* instance, or has to have {@code cloud_controller.admin} authority. If you want to
|
||||
* avoid CF API call, use
|
||||
* {@link BackingAppManagementService#restage(String, String, String)} method.
|
||||
*
|
||||
* @param serviceInstanceId target service instance id
|
||||
* @return completes when the operation is completed
|
||||
*/
|
||||
@@ -206,7 +209,7 @@ public class BackingAppManagementService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Restages the backing applications for the service instance with the given id
|
||||
* Restages the backing applications for the service instance with the given id.
|
||||
* @param serviceInstanceId target service instance id
|
||||
* @param serviceName service name
|
||||
* @param planName plan name
|
||||
@@ -214,11 +217,11 @@ public class BackingAppManagementService {
|
||||
*/
|
||||
public Mono<Void> restage(String serviceInstanceId, String serviceName, String planName) {
|
||||
return getBackingApplicationsForService(serviceInstanceId, serviceName, planName)
|
||||
.flatMapMany(backingApps -> Flux.fromIterable(backingApps)
|
||||
.flatMapMany((backingApps) -> Flux.fromIterable(backingApps)
|
||||
.parallel()
|
||||
.runOn(Schedulers.parallel())
|
||||
.flatMap(managementClient::restage)
|
||||
.doOnRequest(l -> {
|
||||
.flatMap(this.managementClient::restage)
|
||||
.doOnRequest((l) -> {
|
||||
LOG.info("Restaging applications");
|
||||
LOG.debug(BACKINGAPPS_LOG_TEMPLATE, backingApps);
|
||||
})
|
||||
@@ -226,7 +229,7 @@ public class BackingAppManagementService {
|
||||
LOG.info("Finish restaging applications");
|
||||
LOG.debug(BACKINGAPPS_LOG_TEMPLATE, backingApps);
|
||||
})
|
||||
.doOnError(e -> {
|
||||
.doOnError((e) -> {
|
||||
LOG.error(String.format("Error restaging applications. error=%s", e.getMessage()), e);
|
||||
LOG.debug(BACKINGAPPS_LOG_TEMPLATE, backingApps);
|
||||
}))
|
||||
@@ -234,14 +237,16 @@ public class BackingAppManagementService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that fetches service name and plan name from Cloud Foundry Service Instances API (CF API) and
|
||||
* invokes {@code getDeployedBackingApplications(serviceInstanceId, serviceName, planName)}.
|
||||
*
|
||||
* Because this method will try to fetch user-created service instance, UAA client used by the broker has to be a
|
||||
* space developer of the space containing the service instance, or has to have {@code cloud_controller.admin}
|
||||
* authority. If you want to avoid CF API call, use
|
||||
* {@link BackingAppManagementService#getDeployedBackingApplications(String, String, String)} method.
|
||||
* Helper method that fetches service name and plan name from Cloud Foundry Service
|
||||
* Instances API (CF API) and invokes
|
||||
* {@code getDeployedBackingApplications(serviceInstanceId, serviceName, planName)}.
|
||||
*
|
||||
* Because this method will try to fetch user-created service instance, UAA client
|
||||
* used by the broker has to be a space developer of the space containing the service
|
||||
* instance, or has to have {@code cloud_controller.admin} authority. If you want to
|
||||
* avoid CF API call, use
|
||||
* {@link BackingAppManagementService#getDeployedBackingApplications(String, String, String)}
|
||||
* method.
|
||||
* @param serviceInstanceId target service instance id
|
||||
* @return backing applications for the target service instance
|
||||
*/
|
||||
@@ -250,82 +255,77 @@ public class BackingAppManagementService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of backing applications for the service instance with the given id
|
||||
* Returns a list of backing applications for the service instance with the given id.
|
||||
* @param serviceInstanceId target service instance id
|
||||
* @param serviceName service name
|
||||
* @param planName plan name
|
||||
* @return backing applications for the target service instance
|
||||
*/
|
||||
public Mono<BackingApplications> getDeployedBackingApplications(String serviceInstanceId, String serviceName, String planName) {
|
||||
public Mono<BackingApplications> getDeployedBackingApplications(String serviceInstanceId, String serviceName,
|
||||
String planName) {
|
||||
return getBackingApplicationsForService(serviceInstanceId, serviceName, planName)
|
||||
.flatMapMany(Flux::fromIterable)
|
||||
.flatMap(app ->
|
||||
appDeployer
|
||||
.get(GetApplicationRequest.builder()
|
||||
.name(app.getName())
|
||||
.flatMap((app) -> this.appDeployer
|
||||
.get(GetApplicationRequest.builder().name(app.getName()).properties(app.getProperties()).build())
|
||||
.flatMap((response) -> Flux.fromIterable(response.getServices())
|
||||
.map((boundServiceName) -> ServicesSpec.builder().serviceInstanceName(boundServiceName).build())
|
||||
.collectList()
|
||||
.map((services) -> BackingApplication.builder()
|
||||
.name(response.getName())
|
||||
.services(services)
|
||||
.properties(app.getProperties())
|
||||
.build())
|
||||
.flatMap(response -> Flux.fromIterable(response.getServices())
|
||||
.map(boundServiceName ->
|
||||
ServicesSpec.builder()
|
||||
.serviceInstanceName(boundServiceName)
|
||||
.build())
|
||||
.collectList()
|
||||
.map(services -> BackingApplication
|
||||
.builder()
|
||||
.name(response.getName())
|
||||
.services(services)
|
||||
.properties(app.getProperties())
|
||||
.environment(response.getEnvironment())
|
||||
.build()))
|
||||
.doOnRequest(l -> {
|
||||
LOG.info("Getting deployed backing application. appName={}", app.getName());
|
||||
LOG.debug("backingApp={}", app);
|
||||
})
|
||||
.doOnError(e -> {
|
||||
LOG.error(String.format("Error getting deployed backing application. appName=%s, error=%s",
|
||||
.environment(response.getEnvironment())
|
||||
.build()))
|
||||
.doOnRequest((l) -> {
|
||||
LOG.info("Getting deployed backing application. appName={}", app.getName());
|
||||
LOG.debug("backingApp={}", app);
|
||||
})
|
||||
.doOnError((e) -> {
|
||||
LOG.error(String.format("Error getting deployed backing application. appName=%s, error=%s",
|
||||
app.getName(), e.getMessage()), e);
|
||||
LOG.debug("backingApp={}", app);
|
||||
})
|
||||
.onErrorResume(exception -> Mono.empty()))
|
||||
LOG.debug("backingApp={}", app);
|
||||
})
|
||||
.onErrorResume((exception) -> Mono.empty()))
|
||||
.collectList()
|
||||
.map(BackingApplications::new)
|
||||
.doOnSuccess(backingApplications -> LOG.debug("backingApplications={}", backingApplications));
|
||||
.doOnSuccess((backingApplications) -> LOG.debug("backingApplications={}", backingApplications));
|
||||
}
|
||||
|
||||
public Mono<BackingApplications> getBackingApplicationsForService(String serviceInstanceId, String serviceName,
|
||||
String planName) {
|
||||
String planName) {
|
||||
return findBrokeredService(serviceName, planName)
|
||||
.flatMap(brokeredService -> updateBackingApps(brokeredService, serviceInstanceId))
|
||||
.map(backingApplications -> BackingApplications.builder().backingApplications(backingApplications).build());
|
||||
.flatMap((brokeredService) -> updateBackingApps(brokeredService, serviceInstanceId))
|
||||
.map((backingApplications) -> BackingApplications.builder()
|
||||
.backingApplications(backingApplications)
|
||||
.build());
|
||||
}
|
||||
|
||||
private <T> Mono<T> fetchServiceDetailsAndInvoke(String serviceInstanceId, BackingAppAction<T> action) {
|
||||
return appDeployer
|
||||
return this.appDeployer
|
||||
.getServiceInstance(GetServiceInstanceRequest.builder().serviceInstanceId(serviceInstanceId).build())
|
||||
.flatMap(serviceInstance -> action.invoke(serviceInstanceId, serviceInstance.getService(),
|
||||
serviceInstance.getPlan()));
|
||||
.flatMap((serviceInstance) -> action.invoke(serviceInstanceId, serviceInstance.getService(),
|
||||
serviceInstance.getPlan()));
|
||||
}
|
||||
|
||||
private Mono<BrokeredService> findBrokeredService(String serviceName, String planName) {
|
||||
return Flux.fromIterable(brokeredServices)
|
||||
.filter(brokeredService -> brokeredService.getServiceName().equals(serviceName)
|
||||
&& brokeredService.getPlanName().equals(planName))
|
||||
return Flux.fromIterable(this.brokeredServices)
|
||||
.filter((brokeredService) -> brokeredService.getServiceName().equals(serviceName)
|
||||
&& brokeredService.getPlanName().equals(planName))
|
||||
.singleOrEmpty();
|
||||
}
|
||||
|
||||
private Mono<List<BackingApplication>> updateBackingApps(BrokeredService brokeredService,
|
||||
String serviceInstanceId) {
|
||||
return Mono.just(BackingApplications.builder()
|
||||
.backingApplications(brokeredService.getApps())
|
||||
.build())
|
||||
.flatMap(backingApps -> targetService.addToBackingApplications(backingApps,
|
||||
brokeredService.getTarget(), serviceInstanceId));
|
||||
String serviceInstanceId) {
|
||||
return Mono.just(BackingApplications.builder().backingApplications(brokeredService.getApps()).build())
|
||||
.flatMap((backingApps) -> this.targetService.addToBackingApplications(backingApps,
|
||||
brokeredService.getTarget(), serviceInstanceId));
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
private interface BackingAppAction<T> {
|
||||
|
||||
Mono<T> invoke(String serviceInstanceId, String serviceName, String planName);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors
|
||||
* Copyright 2016-2024 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -41,84 +41,88 @@ public class ManagementClient {
|
||||
|
||||
public Mono<Void> start(BackingApplication backingApplication) {
|
||||
return Mono.justOrEmpty(backingApplication)
|
||||
.flatMap(backingApp -> appManager.start(StartApplicationRequest.builder()
|
||||
.name(backingApp.getName())
|
||||
.properties(backingApp.getProperties())
|
||||
.build())
|
||||
.doOnRequest(l -> {
|
||||
.flatMap((backingApp) -> this.appManager
|
||||
.start(StartApplicationRequest.builder()
|
||||
.name(backingApp.getName())
|
||||
.properties(backingApp.getProperties())
|
||||
.build())
|
||||
.doOnRequest((l) -> {
|
||||
LOG.info("Starting application. backingAppName={}", backingApp.getName());
|
||||
LOG.debug(BACKINGAPP_LOG_TEMPLATE, backingApp);
|
||||
})
|
||||
.doOnSuccess(response -> {
|
||||
.doOnSuccess((response) -> {
|
||||
LOG.info("Success starting application. backingAppName={}", backingApp.getName());
|
||||
LOG.debug(BACKINGAPP_LOG_TEMPLATE, backingApp);
|
||||
})
|
||||
.doOnError(e -> {
|
||||
.doOnError((e) -> {
|
||||
LOG.error(String.format("Error starting application. backingAppName=%s, error=%s",
|
||||
backingApp.getName(), e.getMessage()), e);
|
||||
backingApp.getName(), e.getMessage()), e);
|
||||
LOG.debug(BACKINGAPP_LOG_TEMPLATE, backingApp);
|
||||
}));
|
||||
}
|
||||
|
||||
public Mono<Void> stop(BackingApplication backingApplication) {
|
||||
return Mono.justOrEmpty(backingApplication)
|
||||
.flatMap(backingApp -> appManager.stop(StopApplicationRequest.builder()
|
||||
.name(backingApp.getName())
|
||||
.properties(backingApp.getProperties())
|
||||
.build())
|
||||
.doOnRequest(l -> {
|
||||
.flatMap((backingApp) -> this.appManager
|
||||
.stop(StopApplicationRequest.builder()
|
||||
.name(backingApp.getName())
|
||||
.properties(backingApp.getProperties())
|
||||
.build())
|
||||
.doOnRequest((l) -> {
|
||||
LOG.info("Stopping application. backingAppName={}", backingApp.getName());
|
||||
LOG.debug(BACKINGAPP_LOG_TEMPLATE, backingApp);
|
||||
})
|
||||
.doOnSuccess(response -> {
|
||||
.doOnSuccess((response) -> {
|
||||
LOG.info("Success stopping application. backingAppName={}", backingApp.getName());
|
||||
LOG.debug(BACKINGAPP_LOG_TEMPLATE, backingApp);
|
||||
})
|
||||
.doOnError(e -> {
|
||||
.doOnError((e) -> {
|
||||
LOG.error(String.format("Error stopping application. backingAppName=%s, error=%s",
|
||||
backingApp.getName(), e.getMessage()), e);
|
||||
backingApp.getName(), e.getMessage()), e);
|
||||
LOG.debug(BACKINGAPP_LOG_TEMPLATE, backingApp);
|
||||
}));
|
||||
}
|
||||
|
||||
public Mono<Void> restart(BackingApplication backingApplication) {
|
||||
return Mono.justOrEmpty(backingApplication)
|
||||
.flatMap(backingApp -> appManager.restart(RestartApplicationRequest.builder()
|
||||
.name(backingApp.getName())
|
||||
.properties(backingApp.getProperties())
|
||||
.build())
|
||||
.doOnRequest(l -> {
|
||||
.flatMap((backingApp) -> this.appManager
|
||||
.restart(RestartApplicationRequest.builder()
|
||||
.name(backingApp.getName())
|
||||
.properties(backingApp.getProperties())
|
||||
.build())
|
||||
.doOnRequest((l) -> {
|
||||
LOG.info("Restarting application. backingAppName={}", backingApp.getName());
|
||||
LOG.debug(BACKINGAPP_LOG_TEMPLATE, backingApp);
|
||||
})
|
||||
.doOnSuccess(response -> {
|
||||
.doOnSuccess((response) -> {
|
||||
LOG.info("Success restarting application. backingAppName={}", backingApp.getName());
|
||||
LOG.debug(BACKINGAPP_LOG_TEMPLATE, backingApp);
|
||||
})
|
||||
.doOnError(e -> {
|
||||
.doOnError((e) -> {
|
||||
LOG.error(String.format("Error restarting application. backingAppName=%s, error=%s",
|
||||
backingApp.getName(), e.getMessage()), e);
|
||||
backingApp.getName(), e.getMessage()), e);
|
||||
LOG.debug(BACKINGAPP_LOG_TEMPLATE, backingApp);
|
||||
}));
|
||||
}
|
||||
|
||||
public Mono<Void> restage(BackingApplication backingApplication) {
|
||||
return Mono.justOrEmpty(backingApplication)
|
||||
.flatMap(backingApp -> appManager.restage(RestageApplicationRequest.builder()
|
||||
.name(backingApp.getName())
|
||||
.properties(backingApp.getProperties())
|
||||
.build())
|
||||
.doOnRequest(l -> {
|
||||
.flatMap((backingApp) -> this.appManager
|
||||
.restage(RestageApplicationRequest.builder()
|
||||
.name(backingApp.getName())
|
||||
.properties(backingApp.getProperties())
|
||||
.build())
|
||||
.doOnRequest((l) -> {
|
||||
LOG.info("Restaging application. backingAppName={}", backingApp.getName());
|
||||
LOG.debug(BACKINGAPP_LOG_TEMPLATE, backingApp);
|
||||
})
|
||||
.doOnSuccess(response -> {
|
||||
.doOnSuccess((response) -> {
|
||||
LOG.info("Success restaging application. backingAppName={}", backingApp.getName());
|
||||
LOG.debug(BACKINGAPP_LOG_TEMPLATE, backingApp);
|
||||
})
|
||||
.doOnError(e -> {
|
||||
.doOnError((e) -> {
|
||||
LOG.error(String.format("Error restaging application. backingAppName=%s, error=%s",
|
||||
backingApp.getName(), e.getMessage()), e);
|
||||
backingApp.getName(), e.getMessage()), e);
|
||||
LOG.debug(BACKINGAPP_LOG_TEMPLATE, backingApp);
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016-2024 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* App Broker Manager.
|
||||
*/
|
||||
package org.springframework.cloud.appbroker.manager;
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016-2024 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* App Broker Core.
|
||||
*/
|
||||
package org.springframework.cloud.appbroker;
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -25,7 +25,7 @@ import org.springframework.cloud.servicebroker.model.binding.CreateServiceInstan
|
||||
public interface CreateServiceInstanceAppBindingWorkflow {
|
||||
|
||||
default Mono<Void> create(CreateServiceInstanceBindingRequest request,
|
||||
CreateServiceInstanceAppBindingResponse response) {
|
||||
CreateServiceInstanceAppBindingResponse response) {
|
||||
return Mono.empty();
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ public interface CreateServiceInstanceAppBindingWorkflow {
|
||||
}
|
||||
|
||||
default Mono<CreateServiceInstanceAppBindingResponseBuilder> buildResponse(
|
||||
CreateServiceInstanceBindingRequest request,
|
||||
CreateServiceInstanceAppBindingResponseBuilder responseBuilder) {
|
||||
CreateServiceInstanceBindingRequest request,
|
||||
CreateServiceInstanceAppBindingResponseBuilder responseBuilder) {
|
||||
return Mono.just(responseBuilder);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -25,7 +25,7 @@ import org.springframework.cloud.servicebroker.model.binding.CreateServiceInstan
|
||||
public interface CreateServiceInstanceRouteBindingWorkflow {
|
||||
|
||||
default Mono<Void> create(CreateServiceInstanceBindingRequest request,
|
||||
CreateServiceInstanceRouteBindingResponse response) {
|
||||
CreateServiceInstanceRouteBindingResponse response) {
|
||||
return Mono.empty();
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ public interface CreateServiceInstanceRouteBindingWorkflow {
|
||||
}
|
||||
|
||||
default Mono<CreateServiceInstanceRouteBindingResponseBuilder> buildResponse(
|
||||
CreateServiceInstanceBindingRequest request,
|
||||
CreateServiceInstanceRouteBindingResponseBuilder responseBuilder) {
|
||||
CreateServiceInstanceBindingRequest request,
|
||||
CreateServiceInstanceRouteBindingResponseBuilder responseBuilder) {
|
||||
return Mono.just(responseBuilder);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -24,8 +24,7 @@ import org.springframework.cloud.servicebroker.model.instance.CreateServiceInsta
|
||||
|
||||
public interface CreateServiceInstanceWorkflow {
|
||||
|
||||
default Mono<Void> create(CreateServiceInstanceRequest request,
|
||||
CreateServiceInstanceResponse response) {
|
||||
default Mono<Void> create(CreateServiceInstanceRequest request, CreateServiceInstanceResponse response) {
|
||||
return Mono.empty();
|
||||
}
|
||||
|
||||
@@ -34,7 +33,7 @@ public interface CreateServiceInstanceWorkflow {
|
||||
}
|
||||
|
||||
default Mono<CreateServiceInstanceResponseBuilder> buildResponse(CreateServiceInstanceRequest request,
|
||||
CreateServiceInstanceResponseBuilder responseBuilder) {
|
||||
CreateServiceInstanceResponseBuilder responseBuilder) {
|
||||
return Mono.just(responseBuilder);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user