org.cloudfoundry.operations.applications.Route Java Examples

The following examples show how to use org.cloudfoundry.operations.applications.Route. 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: CfPropertiesMapper.java    From ya-cf-app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
public List<String> getAppRoutes() {
    return firstNonEmptyOptional(() -> getListPropertyFromProject(PropertyNameConstants.CF_APPLICATION_ROUTES),
        () -> Optional.ofNullable(this.getExtension().getRoutes().isEmpty() ? null : this.getExtension().getRoutes()),
        () -> fromManifest(m -> m.getRoutes().stream().map(Route::getRoute).collect(Collectors.toList())),
        () -> Optional.ofNullable(Collections.emptyList())
    );
}
 
Example #2
Source File: CfManifestUtil.java    From ya-cf-app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
public static ApplicationManifest convert(CfProperties properties) {
    ApplicationManifest.Builder builder = ApplicationManifest.builder();
    if(properties.manifestPath() != null)
        builder.from(ApplicationManifestUtils.read(new File(properties.manifestPath()).toPath()).get(0));

    builder
        .buildpack(properties.buildpack())
        .command(properties.command())
        .disk(properties.diskQuota())
        .environmentVariables(properties.environment())
        .instances(properties.instances())
        .memory(properties.memory())
        .name(properties.name())
        .timeout(properties.timeout());
    if(properties.filePath() != null)
        builder.path(new File(properties.filePath()).toPath());
    if(properties.services() != null && !properties.services().isEmpty())
        builder.services(properties.services());
    if(properties.host() != null)
        builder.host(properties.host());
    if(properties.domain() != null)
        builder.domain(properties.domain());
    if(properties.path() != null)
        builder.routePath(properties.path());
    if(properties.healthCheckType() != null)
        builder.healthCheckType(ApplicationHealthCheck.from(properties.healthCheckType()));
    if(properties.routes() != null && !properties.routes().isEmpty())
       builder.routes(properties.routes().stream().map(s -> Route.builder().route(s).build()).collect(Collectors.toList()));
    return builder.build();
}
 
Example #3
Source File: CloudFoundryAppDeployerTest.java    From spring-cloud-app-broker with Apache License 2.0 4 votes vote down vote up
@Test
void deployAppWithRoutesAndMutuallyExclusiveProperties() {
	deploymentProperties.setCount(3);
	deploymentProperties.setMemory("2G");
	deploymentProperties.setDisk("3G");
	deploymentProperties.setBuildpack("buildpack1");
	deploymentProperties.setHealthCheck(ApplicationHealthCheck.HTTP);
	deploymentProperties.setHealthCheckHttpEndpoint("/healthcheck1");
	deploymentProperties.setHost("host1");
	deploymentProperties.setDomain("domain1");
	deploymentProperties.setDomains(singleton("domain2"));

	DeployApplicationRequest request = DeployApplicationRequest.builder()
		.name(APP_NAME)
		.path(APP_PATH)
		.serviceInstanceId(SERVICE_INSTANCE_ID)
		.property(DeploymentProperties.COUNT_PROPERTY_KEY, "5")
		.property(DeploymentProperties.MEMORY_PROPERTY_KEY, "4G")
		.property(DeploymentProperties.DISK_PROPERTY_KEY, "5G")
		.property(CloudFoundryDeploymentProperties.HEALTHCHECK_PROPERTY_KEY, "port")
		.property(CloudFoundryDeploymentProperties.HEALTHCHECK_HTTP_ENDPOINT_PROPERTY_KEY, "/healthcheck2")
		.property(CloudFoundryDeploymentProperties.BUILDPACK_PROPERTY_KEY, "buildpack2")
		.property(CloudFoundryDeploymentProperties.DOMAIN_PROPERTY, "domain1")
		.property(CloudFoundryDeploymentProperties.DOMAINS_PROPERTY, "domain2")
		.property(CloudFoundryDeploymentProperties.ROUTES_PROPERTY, "route.domain3")
		.build();

	StepVerifier.create(appDeployer.deploy(request))
				.assertNext(response -> assertThat(response.getName()).isEqualTo(APP_NAME))
				.verifyComplete();

	ApplicationManifest expectedManifest = baseManifestWithSpringAppJson()
		.name(APP_NAME)
		.path(new File(APP_PATH).toPath())
		.instances(5)
		.memory(4096)
		.disk(5120)
		.healthCheckType(ApplicationHealthCheck.PORT)
		.healthCheckHttpEndpoint("/healthcheck2")
		.buildpack("buildpack2")
		.routes(Route.builder().route("route.domain3").build())
		.build();

	then(operationsApplications).should().pushManifest(argThat(matchesManifest(expectedManifest)));
}
 
Example #4
Source File: CloudFoundryAppDeployerTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void deployWithMultipleRoutes() throws IOException {
	Resource resource = new FileSystemResource("src/test/resources/demo-0.0.1-SNAPSHOT.jar");

	given(this.applicationNameGenerator.generateAppName("test-application")).willReturn("test-application-id");

	givenRequestGetApplication("test-application-id",
			Mono.error(new IllegalArgumentException()),
			Mono.just(ApplicationDetail.builder()
					.diskQuota(0)
					.id("test-application-id")
					.instances(1)
					.memoryLimit(0)
					.name("test-application")
					.requestedState("RUNNING")
					.runningInstances(0)
					.stack("test-stack")
					.build()));

	this.deploymentProperties.setBuildpack("test-buildpack");
	this.deploymentProperties.setDisk("0");
	this.deploymentProperties.setHealthCheck(ApplicationHealthCheck.NONE);
	this.deploymentProperties.setRoutes(Sets.newHashSet("route1.test-domain", "route2.test-domain"));
	this.deploymentProperties.setInstances(0);
	this.deploymentProperties.setMemory("0");

	givenRequestPushApplication(PushApplicationManifestRequest.builder()
			.manifest(ApplicationManifest.builder()
					.path(resource.getFile().toPath())
					.buildpack("test-buildpack")
					.disk(0)
					.routes(Sets.newHashSet(
							Route.builder().route("route1.test-domain").build(),
							Route.builder().route("route2.test-domain").build()
					))
					.environmentVariables(defaultEnvironmentVariables())
					.healthCheckType(ApplicationHealthCheck.NONE)
					.instances(0)
					.memory(0)
					.name("test-application-id")
					.service("test-service-2")
					.service("test-service-1")
					.build())
			.stagingTimeout(this.deploymentProperties.getStagingTimeout())
			.startupTimeout(this.deploymentProperties.getStartupTimeout())
			.build(), Mono.empty());

	String deploymentId = this.deployer.deploy(new AppDeploymentRequest(
			new AppDefinition("test-application", Collections.emptyMap()),
			resource,
			Collections.emptyMap()));

	assertThat(deploymentId, equalTo("test-application-id"));
}