use of io.javaoperatorsdk.operator.api.reconciler.UpdateControl in project java-operator-sdk by java-operator-sdk.
the class DeploymentReconciler method reconcile.
@Override
public UpdateControl<Deployment> reconcile(Deployment resource, Context context) {
log.info("Reconcile deployment: {}", resource);
numberOfExecutions.incrementAndGet();
if (resource.getStatus() == null) {
resource.setStatus(new DeploymentStatus());
}
if (resource.getStatus().getConditions() == null) {
resource.getStatus().setConditions(new ArrayList<>());
}
var conditions = resource.getStatus().getConditions();
var condition = conditions.stream().filter(c -> c.getMessage().equals(STATUS_MESSAGE)).findFirst();
if (condition.isEmpty()) {
conditions.add(new DeploymentCondition(null, null, STATUS_MESSAGE, null, "unknown", "DeploymentReconciler"));
return UpdateControl.updateStatus(resource);
} else {
return UpdateControl.noUpdate();
}
}
Aggregations