use of com.enonic.kubernetes.client.v1.domain.DomainStatus in project xp-operator by enonic.
the class MutationApi method domain.
private void domain(final MutationRequest mt) {
// Collect old and new object
Domain oldR = (Domain) mt.getAdmissionReview().getRequest().getOldObject();
Domain newR = (Domain) mt.getAdmissionReview().getRequest().getObject();
// Create default status
DomainStatus defStatus = new DomainStatus().withState(DomainStatus.State.PENDING).withMessage("Waiting for DNS records").withDomainStatusFields(new DomainStatusFields(lbServiceIpProducer.get(), false));
// Get OP
AdmissionOperation op = getOperation(mt.getAdmissionReview());
// Ensure status
switch(op) {
case // Always set the default status on new objects
CREATE:
patch(mt, true, "/status", newR.getStatus(), defStatus);
break;
case UPDATE:
if (newR.getSpec() != null && !newR.getSpec().equals(oldR.getSpec())) {
// On any change change, set default status
patch(mt, true, "/status", newR.getStatus(), defStatus);
} else {
// Else make sure the old status is not removed
patch(mt, false, "/status", newR.getStatus(), oldR.getStatus());
}
break;
case DELETE:
// Do nothing
break;
}
if (newR.getSpec() != null) {
// Set default TTL
patch(mt, false, "/spec/dnsTTL", newR.getSpec().getDnsTTL(), 3600);
}
}
Aggregations