org.springframework.cloud.deployer.spi.cloudfoundry.CloudFoundryConnectionProperties Java Examples

The following examples show how to use org.springframework.cloud.deployer.spi.cloudfoundry.CloudFoundryConnectionProperties. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CloudFoundryTestSupport.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 6 votes vote down vote up
@Bean
public CloudFoundryOperations cloudFoundryOperations(CloudFoundryClient cloudFoundryClient,
													 ConnectionContext connectionContext,
													 TokenProvider tokenProvider,
													 CloudFoundryConnectionProperties properties) {
	ReactorDopplerClient.builder()
		.connectionContext(connectionContext)
		.tokenProvider(tokenProvider)
		.build();

	ReactorUaaClient.builder()
		.connectionContext(connectionContext)
		.tokenProvider(tokenProvider)
		.build();

	return DefaultCloudFoundryOperations.builder()
		.cloudFoundryClient(cloudFoundryClient)
		.organization(properties.getOrg())
		.space(properties.getSpace())
		.build();
}
 
Example #2
Source File: CloudFoundryTaskPlatformFactoryTests.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
	when(this.cloudFoundryClient.info())
			.thenReturn(getInfoRequest -> Mono.just(GetInfoResponse.builder().apiVersion("0.0.0").build()));
	when(this.cloudFoundryClient.organizations()).thenReturn(mock(Organizations.class));
	when(this.cloudFoundryClient.spaces()).thenReturn(mock(Spaces.class));
	when(this.cloudFoundryClient.organizations().list(any())).thenReturn(listOrganizationsResponse());
	when(this.cloudFoundryClient.spaces().list(any())).thenReturn(listSpacesResponse());
	when(this.cloudFoundryClientProvider.cloudFoundryClient(anyString())).thenReturn(this.cloudFoundryClient);
	this.cloudFoundryPlatformProperties = new CloudFoundryPlatformProperties();

	this.defaultConnectionProperties = new CloudFoundryConnectionProperties();
	this.defaultConnectionProperties.setOrg("org");
	this.defaultConnectionProperties.setSpace("space");
	this.defaultConnectionProperties.setUrl(new URL("https://localhost:9999"));

	this.deploymentProperties = new CloudFoundryDeploymentProperties();
	this.deploymentProperties.setApiTimeout(1L);
}
 
Example #3
Source File: CloudFoundryTaskPlatformFactory.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@Override
public Launcher createLauncher(String account) {
	ConnectionContext connectionContext = connectionContext(account);
	TokenProvider tokenProvider = tokenProvider(account);
	CloudFoundryClient cloudFoundryClient = cloudFoundryClient(account);
	CloudFoundryOperations cloudFoundryOperations = cloudFoundryOperations(cloudFoundryClient, account);
	CloudFoundryTaskLauncher taskLauncher = new CloudFoundryTaskLauncher(
			cloudFoundryClient,
			deploymentProperties(account),
			cloudFoundryOperations,
			runtimeEnvironmentInfo(cloudFoundryClient, account));
	Launcher launcher = new Launcher(account, CLOUDFOUNDRY_PLATFORM_TYPE, taskLauncher,
			scheduler(account, taskLauncher, cloudFoundryOperations));
	CloudFoundryConnectionProperties connectionProperties = connectionProperties(account);
	launcher.setDescription(String.format("org = [%s], space = [%s], url = [%s]",
			connectionProperties.getOrg(), connectionProperties.getSpace(),
			connectionProperties.getUrl()));
	return launcher;
}
 
Example #4
Source File: CloudFoundrySchedulerConfiguration.java    From spring-cloud-dataflow-server-cloudfoundry with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public Scheduler scheduler(ReactorSchedulerClient client,
		CloudFoundryOperations operations,
		CloudFoundryConnectionProperties properties,
		TaskLauncher taskLauncher,
		CloudFoundrySchedulerProperties schedulerProperties) {
	return new CloudFoundryAppScheduler(client, operations, properties,
			(CloudFoundry2630AndLaterTaskLauncher) taskLauncher,
			schedulerProperties);
}
 
Example #5
Source File: CloudFoundryAppScheduler.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
public CloudFoundryAppScheduler(SchedulerClient client, CloudFoundryOperations operations,
		CloudFoundryConnectionProperties properties, CloudFoundryTaskLauncher taskLauncher,
		CloudFoundrySchedulerProperties schedulerProperties) {
	Assert.notNull(client, "client must not be null");
	Assert.notNull(operations, "operations must not be null");
	Assert.notNull(properties, "properties must not be null");
	Assert.notNull(taskLauncher, "taskLauncher must not be null");
	Assert.notNull(schedulerProperties, "schedulerProperties must not be null");

	this.client = client;
	this.operations = operations;
	this.properties = properties;
	this.taskLauncher = taskLauncher;
	this.schedulerProperties = schedulerProperties;
}
 
Example #6
Source File: SpringCloudSchedulerIntegrationTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public Scheduler scheduler(ReactorSchedulerClient client,
		CloudFoundryOperations operations,
		CloudFoundryConnectionProperties properties,
		TaskLauncher taskLauncher,
		CloudFoundrySchedulerProperties schedulerProperties) {
	return new CloudFoundryAppScheduler(client, operations, properties,
			(CloudFoundryTaskLauncher) taskLauncher,
			schedulerProperties);
}
 
Example #7
Source File: CloudFoundryTestSupport.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
@Bean
public ConnectionContext connectionContext(CloudFoundryConnectionProperties properties) {
	return DefaultConnectionContext.builder()
			.apiHost(properties.getUrl().getHost())
			.skipSslValidation(properties.isSkipSslValidation())
			.build();
}
 
Example #8
Source File: CloudFoundryTestSupport.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
@Bean
public TokenProvider tokenProvider(CloudFoundryConnectionProperties properties) {
	return PasswordGrantTokenProvider.builder()
			.username(properties.getUsername())
			.password(properties.getPassword())
			.loginHint(properties.getLoginHint())
			.build();
}
 
Example #9
Source File: CloudFoundryTaskPlatformFactoryTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
private void setupMultiPlatform() throws Exception{
	this.anotherOrgSpaceConnectionProperties = new CloudFoundryConnectionProperties();
	this.anotherOrgSpaceConnectionProperties.setOrg("another-org");
	this.anotherOrgSpaceConnectionProperties.setSpace("another-space");
	this.anotherOrgSpaceConnectionProperties.setUrl(new URL("https://localhost:9999"));


	CloudFoundryProperties cloudFoundryProperties = new CloudFoundryProperties();
	CloudFoundrySchedulerProperties cloudFoundrySchedulerProperties = new CloudFoundrySchedulerProperties();
	cloudFoundrySchedulerProperties.setSchedulerUrl("https://localhost:9999");
	cloudFoundryProperties.setSchedulerProperties(cloudFoundrySchedulerProperties);
	cloudFoundryProperties.setDeployment(new CloudFoundryDeploymentProperties());
	cloudFoundryProperties.setConnection(this.defaultConnectionProperties);
	Map<String, CloudFoundryProperties> platformMap = new HashMap<>();
	platformMap.put("default", cloudFoundryProperties);
	cloudFoundryProperties = new CloudFoundryProperties();
	cloudFoundryProperties.setDeployment(new CloudFoundryDeploymentProperties());
	cloudFoundryProperties.setConnection(this.anotherOrgSpaceConnectionProperties);
	cloudFoundryProperties.setSchedulerProperties(cloudFoundrySchedulerProperties);


	platformMap.put("anotherOrgSpace", cloudFoundryProperties);

	this.cloudFoundryPlatformProperties.setAccounts(platformMap);

	this.connectionContextProvider = new CloudFoundryPlatformConnectionContextProvider(this.cloudFoundryPlatformProperties);
	this.platformTokenProvider = mock(CloudFoundryPlatformTokenProvider.class);
	when(this.platformTokenProvider.tokenProvider(anyString())).thenReturn(mock(TokenProvider.class));
}
 
Example #10
Source File: PlatformCloudFoundryOperations.java    From spring-cloud-skipper with Apache License 2.0 5 votes vote down vote up
private CloudFoundryOperations buildCloudFoundryOperations(String platformName) {
	CloudFoundryPlatformProperties.CloudFoundryProperties cloudFoundryProperties = this.cloudFoundryPlatformProperties
			.getAccounts()
			.get(platformName);
	CloudFoundryConnectionProperties connectionProperties = cloudFoundryProperties.getConnection();
	ConnectionContext connectionContext = DefaultConnectionContext.builder()
			.apiHost(connectionProperties.getUrl().getHost())
			.skipSslValidation(connectionProperties.isSkipSslValidation())
			.build();
	Builder tokenProviderBuilder = PasswordGrantTokenProvider.builder()
			.username(connectionProperties.getUsername())
			.password(connectionProperties.getPassword())
			.loginHint(connectionProperties.getLoginHint());
	if (StringUtils.hasText(connectionProperties.getClientId())) {
		tokenProviderBuilder.clientId(connectionProperties.getClientId());
	}
	if (StringUtils.hasText(connectionProperties.getClientSecret())) {
		tokenProviderBuilder.clientSecret(connectionProperties.getClientSecret());
	}
	TokenProvider tokenProvider = tokenProviderBuilder.build();
	CloudFoundryClient cloudFoundryClient = ReactorCloudFoundryClient.builder()
			.connectionContext(connectionContext)
			.tokenProvider(tokenProvider)
			.build();
	return DefaultCloudFoundryOperations
			.builder().cloudFoundryClient(cloudFoundryClient)
			.organization(connectionProperties.getOrg())
			.space(connectionProperties.getSpace()).build();
}
 
Example #11
Source File: CloudFoundryPlatformTokenProvider.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
public TokenProvider tokenProvider(String account) {
	CloudFoundryConnectionProperties connectionProperties = platformProperties.accountProperties(account)
			.getConnection();
	Builder tokenProviderBuilder = PasswordGrantTokenProvider.builder()
			.username(connectionProperties.getUsername())
			.password(connectionProperties.getPassword())
			.loginHint(connectionProperties.getLoginHint());
	if (StringUtils.hasText(connectionProperties.getClientId())) {
		tokenProviderBuilder.clientId(connectionProperties.getClientId());
	}
	if (StringUtils.hasText(connectionProperties.getClientSecret())) {
		tokenProviderBuilder.clientSecret(connectionProperties.getClientSecret());
	}
	return tokenProviderBuilder.build();
}
 
Example #12
Source File: CloudFoundryPlatformConnectionContextProvider.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
public ConnectionContext connectionContext(String account) {
	CloudFoundryConnectionProperties connectionProperties =
		this.platformProperties.accountProperties(account).getConnection();
	this.connectionContexts.putIfAbsent(account, DefaultConnectionContext.builder()
		.apiHost(connectionProperties.getUrl().getHost())
		.skipSslValidation(connectionProperties.isSkipSslValidation())
		.build());
	return connectionContexts.get(account);
}
 
Example #13
Source File: CloudFoundryPlatformProperties.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
public CloudFoundryConnectionProperties getConnection() {
	return connection;
}
 
Example #14
Source File: CloudFoundryDataFlowServerConfiguration.java    From spring-cloud-dataflow-server-cloudfoundry with Apache License 2.0 4 votes vote down vote up
@Bean
@ConfigurationProperties(prefix = CloudFoundryConnectionProperties.CLOUDFOUNDRY_PROPERTIES + ".task")
public CloudFoundryDeploymentProperties taskDeploymentProperties() {
	return new CloudFoundryDeploymentProperties();
}
 
Example #15
Source File: CloudFoundryDataFlowServerConfiguration.java    From spring-cloud-dataflow-server-cloudfoundry with Apache License 2.0 4 votes vote down vote up
@Bean
@ConfigurationProperties(prefix = CloudFoundryConnectionProperties.CLOUDFOUNDRY_PROPERTIES + ".stream")
public CloudFoundryDeploymentProperties appDeploymentProperties() {
	return new CloudFoundryDeploymentProperties();
}
 
Example #16
Source File: CloudFoundryTaskPlatformFactory.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
private CloudFoundryConnectionProperties connectionProperties(String account) {
	return platformProperties.accountProperties(account).getConnection();
}
 
Example #17
Source File: CloudFoundryPlatformProperties.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
public void setConnection(CloudFoundryConnectionProperties connection) {
	this.connection = connection;
}
 
Example #18
Source File: CloudFoundryDataFlowServerConfiguration.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
@Bean
@ConfigurationProperties(prefix = CloudFoundryConnectionProperties.CLOUDFOUNDRY_PROPERTIES + ".task")
public CloudFoundryDeploymentProperties taskDeploymentProperties() {
	return new CloudFoundryDeploymentProperties();
}
 
Example #19
Source File: AbstractSchedulerPerPlatformTest.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
@Bean
@Primary
public CloudFoundryConnectionProperties cloudFoundryConnectionProperties() {
	return Mockito.mock(CloudFoundryConnectionProperties.class);
}
 
Example #20
Source File: CloudFoundryTestSupport.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
@Bean
@ConfigurationProperties(prefix = CloudFoundryConnectionProperties.CLOUDFOUNDRY_PROPERTIES)
public CloudFoundryConnectionProperties cloudFoundryConnectionProperties() {
	return new CloudFoundryConnectionProperties();
}
 
Example #21
Source File: CloudFoundryPlatformProperties.java    From spring-cloud-skipper with Apache License 2.0 4 votes vote down vote up
public void setConnection(CloudFoundryConnectionProperties connection) {
	this.connection = connection;
}
 
Example #22
Source File: CloudFoundryPlatformProperties.java    From spring-cloud-skipper with Apache License 2.0 4 votes vote down vote up
public CloudFoundryConnectionProperties getConnection() {
	return connection;
}