Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,11 @@ static Map<String, Object> toApplicationYaml(_ApplicationManifestCommon applicat
if (null != disk) {
putIfPresent(yaml, "disk_quota", applicationManifest.getDisk().toString() + "M");
}
putIfPresent(yaml, "docker", applicationManifest.getDocker());
putIfPresent(
yaml,
"docker",
applicationManifest.getDocker(),
ApplicationManifestUtilsCommon::toDockerYaml);
putIfPresent(yaml, "domains", applicationManifest.getDomains());
putIfPresent(yaml, "env", applicationManifest.getEnvironmentVariables());
putIfPresent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private static ManifestV3Process getProcess(

asString(raw, "type", variables, builder::type);
asString(raw, "command", variables, builder::command);
asString(raw, "disk", variables, builder::disk);
asString(raw, "disk_quota", variables, builder::disk);
asString(raw, "health-check-http-endpoint", variables, builder::healthCheckHttpEndpoint);
asInteger(
raw,
Expand Down Expand Up @@ -315,8 +315,13 @@ private static Map<String, Object> toProcessYaml(ManifestV3Process process) {
putIfPresent(yaml, "health-check-http-endpoint", process.getHealthCheckHttpEndpoint());
putIfPresent(
yaml, "health-check-invocation-timeout", process.getHealthCheckInvocationTimeout());
putIfPresent(yaml, "health-check-type", process.getHealthCheckType().getValue());
putIfPresent(yaml, "readiness-health-check-type", process.getReadinessHealthCheckType());
putIfPresent(
yaml, "health-check-type", process.getHealthCheckType(), HealthCheckType::getValue);
putIfPresent(
yaml,
"readiness-health-check-type",
process.getReadinessHealthCheckType(),
ReadinessHealthCheckType::getValue);
putIfPresent(
yaml,
"readiness-health-check-http-endpoint",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package org.cloudfoundry.operations.applications;

import static org.junit.jupiter.api.Assertions.*;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import org.cloudfoundry.client.v3.processes.ReadinessHealthCheckType;
import org.junit.jupiter.api.Test;

class ApplicationManifestUtilsV3Test {
@Test
void testGenericApplication() throws IOException {
ManifestV3 manifest =
ManifestV3.builder()
.application(
ManifestV3Application.builder()
.name("test-app")
.buildpack("test-buildpack")
.command("test-command")
.disk(512)
.healthCheckHttpEndpoint("test-health-check-http-endpoint")
.instances(2)
.memory(512)
.randomRoute(true)
.stack("test-stack")
.timeout(120)
.environmentVariable("TEST_KEY_1", "test-value-1")
.processe(
ManifestV3Process.builder()
.type("web")
.command("test-command-1")
.readinessHealthCheckType(
ReadinessHealthCheckType.HTTP)
.readinessHealthCheckHttpEndpoint(
"test-readiness-health-check-http-endpoint")
.readinessHealthCheckInvocationTimeout(120)
.build())
.service(
ManifestV3Service.builder()
.name("test-service-1")
.build())
.build())
.build();

assertSerializeDeserialize(manifest);
}

@Test
void testWithDockerApp() throws IOException {
ManifestV3 manifest =
ManifestV3.builder()
.application(
ManifestV3Application.builder()
.name("test-app")
.docker(Docker.builder().image("test-image").build())
.build())
.build();

assertSerializeDeserialize(manifest);
}

private void assertSerializeDeserialize(ManifestV3 manifest) throws IOException {
Path file = Files.createTempFile("test-manifest-", ".yml");
ApplicationManifestUtilsV3.write(file, manifest);
ManifestV3 read = ApplicationManifestUtilsV3.read(file);

assertEquals(manifest, read);
}
}