Skip to content

Commit e1eb373

Browse files
committed
Add Diego flag
Previously pushing Docker applications did not explicitly set the diego flag, which must be 'true' for Docker apps. This commit adds an explicit set to the diego flag. [#128443257][Resolves #550]
1 parent 49f62ce commit e1eb373

File tree

2 files changed

+43
-17
lines changed

2 files changed

+43
-17
lines changed

cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/DefaultApplications.java

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,7 @@ private static Mono<String> getApplicationId(CloudFoundryClient cloudFoundryClie
603603
.then(applicationId -> requestUpdateApplication(cloudFoundryClient, applicationId, request, stackId)
604604
.map(ResourceUtils::getId))
605605
.otherwiseIfEmpty(requestCreateApplication(cloudFoundryClient, request, spaceId, stackId)
606-
.map(ResourceUtils::getId)
607-
);
606+
.map(ResourceUtils::getId));
608607
}
609608

610609
private static Mono<String> getApplicationIdFromOrgSpace(CloudFoundryClient cloudFoundryClient, String application, String spaceId, String organization, String space) {
@@ -918,20 +917,25 @@ private static Mono<CopyApplicationResponse> requestCopyBits(CloudFoundryClient
918917
}
919918

920919
private static Mono<CreateApplicationResponse> requestCreateApplication(CloudFoundryClient cloudFoundryClient, PushApplicationRequest request, String spaceId, String stackId) {
920+
CreateApplicationRequest.Builder builder = CreateApplicationRequest.builder()
921+
.buildpack(request.getBuildpack())
922+
.command(request.getCommand())
923+
.diskQuota(request.getDiskQuota())
924+
.healthCheckTimeout(request.getTimeout())
925+
.healthCheckType(Optional.ofNullable(request.getHealthCheckType()).map(ApplicationHealthCheck::getValue).orElse(null))
926+
.instances(request.getInstances())
927+
.memory(request.getMemory())
928+
.name(request.getName())
929+
.spaceId(spaceId)
930+
.stackId(stackId);
931+
932+
Optional.ofNullable(request.getDockerImage())
933+
.ifPresent(dockerImage -> builder
934+
.diego(true)
935+
.dockerImage(dockerImage));
936+
921937
return cloudFoundryClient.applicationsV2()
922-
.create(CreateApplicationRequest.builder()
923-
.buildpack(request.getBuildpack())
924-
.command(request.getCommand())
925-
.diskQuota(request.getDiskQuota())
926-
.dockerImage(request.getDockerImage())
927-
.healthCheckTimeout(request.getTimeout())
928-
.healthCheckType(Optional.ofNullable(request.getHealthCheckType()).map(ApplicationHealthCheck::getValue).orElse(null))
929-
.instances(request.getInstances())
930-
.memory(request.getMemory())
931-
.name(request.getName())
932-
.spaceId(spaceId)
933-
.stackId(stackId)
934-
.build());
938+
.create(builder.build());
935939
}
936940

937941
private static Mono<CreateRouteResponse> requestCreateRoute(CloudFoundryClient cloudFoundryClient, String domainId, String host, String routePath, String spaceId) {

cloudfoundry-operations/src/test/java/org/cloudfoundry/operations/applications/DefaultApplicationsTest.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,6 @@ private static void requestCreateApplication(CloudFoundryClient cloudFoundryClie
497497
.buildpack(request.getBuildpack())
498498
.command(request.getCommand())
499499
.diskQuota(request.getDiskQuota())
500-
.dockerImage(request.getDockerImage())
501500
.healthCheckTimeout(request.getTimeout())
502501
.healthCheckType(Optional.ofNullable(request.getHealthCheckType()).map(ApplicationHealthCheck::getValue).orElse(null))
503502
.instances(request.getInstances())
@@ -512,7 +511,30 @@ private static void requestCreateApplication(CloudFoundryClient cloudFoundryClie
512511
.id(applicationId)
513512
.build())
514513
.build()));
514+
}
515515

516+
private static void requestCreateDockerApplication(CloudFoundryClient cloudFoundryClient, PushApplicationRequest request, String spaceId, String stackId, String applicationId) {
517+
when(cloudFoundryClient.applicationsV2()
518+
.create(CreateApplicationRequest.builder()
519+
.buildpack(request.getBuildpack())
520+
.command(request.getCommand())
521+
.diego(true)
522+
.diskQuota(request.getDiskQuota())
523+
.dockerImage(request.getDockerImage())
524+
.healthCheckTimeout(request.getTimeout())
525+
.healthCheckType(Optional.ofNullable(request.getHealthCheckType()).map(ApplicationHealthCheck::getValue).orElse(null))
526+
.instances(request.getInstances())
527+
.memory(request.getMemory())
528+
.name(request.getName())
529+
.spaceId(spaceId)
530+
.stackId(stackId)
531+
.build()))
532+
.thenReturn(Mono
533+
.just(fill(CreateApplicationResponse.builder(), "create-")
534+
.metadata(fill(Metadata.builder())
535+
.id(applicationId)
536+
.build())
537+
.build()));
516538
}
517539

518540
private static void requestCreateRoute(CloudFoundryClient cloudFoundryClient, String domainId, String host, String path, String spaceId, String routeId) {
@@ -2515,7 +2537,7 @@ public static final class PushDocker extends AbstractOperationsApiTest<Void> {
25152537
@Before
25162538
public void setUp() throws Exception {
25172539
requestApplicationsEmpty(this.cloudFoundryClient, "test-name", TEST_SPACE_ID);
2518-
requestCreateApplication(this.cloudFoundryClient, this.pushApplicationRequest, TEST_SPACE_ID, null, "test-application-id");
2540+
requestCreateDockerApplication(this.cloudFoundryClient, this.pushApplicationRequest, TEST_SPACE_ID, null, "test-application-id");
25192541
requestSpace(this.cloudFoundryClient, TEST_SPACE_ID, TEST_ORGANIZATION_ID);
25202542
requestPrivateDomain(this.cloudFoundryClient, "test-domain", TEST_ORGANIZATION_ID, "test-domain-id");
25212543
requestRoutesEmpty(this.cloudFoundryClient, "test-domain-id", "test-name", null);

0 commit comments

Comments
 (0)