Skip to content

Commit

Permalink
feat: WorkflowReconcileResult is not optional anymore
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Laprun <[email protected]>
  • Loading branch information
metacosm committed Jan 25, 2024
1 parent bd73e98 commit dc35f9d
Showing 1 changed file with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,19 @@ public void initContext(ExposedApp exposedApp, Context context) {
public UpdateControl<ExposedApp> reconcile(ExposedApp exposedApp, Context<ExposedApp> context) {
final var name = exposedApp.getMetadata().getName();
// retrieve the workflow reconciliation result and re-schedule if we have dependents that are not yet ready
return context.managedDependentResourceContext().getWorkflowReconcileResult()
.map(wrs -> {
if (wrs.allDependentResourcesReady()) {
final var wrs = context.managedDependentResourceContext().getWorkflowReconcileResult();
if (wrs.allDependentResourcesReady()) {

final var url = IngressDependent.getExposedURL(
context.getSecondaryResource(Ingress.class).orElseThrow());
exposedApp.setStatus(new ExposedAppStatus(url, exposedApp.getSpec().getEndpoint()));
log.info("App {} is exposed and ready to be used at {}", name, exposedApp.getStatus().getHost());
return UpdateControl.updateStatus(exposedApp);
} else {
final var duration = Duration.ofSeconds(1);
log.info("App {} is not ready yet, rescheduling reconciliation after {}s", name, duration.toSeconds());
return UpdateControl.<ExposedApp> noUpdate().rescheduleAfter(duration);
}
}).orElseThrow();
final var url = IngressDependent.getExposedURL(
context.getSecondaryResource(Ingress.class).orElseThrow());
exposedApp.setStatus(new ExposedAppStatus(url, exposedApp.getSpec().getEndpoint()));
log.info("App {} is exposed and ready to be used at {}", name, exposedApp.getStatus().getHost());
return UpdateControl.updateStatus(exposedApp);
} else {
final var duration = Duration.ofSeconds(1);
log.info("App {} is not ready yet, rescheduling reconciliation after {}s", name, duration.toSeconds());
return UpdateControl.<ExposedApp> noUpdate().rescheduleAfter(duration);
}
}

static ObjectMeta createMetadata(ExposedApp resource, Map<String, String> labels) {
Expand Down

0 comments on commit dc35f9d

Please sign in to comment.