use of com.enonic.kubernetes.client.v1.xp7config.Xp7ConfigStatus in project xp-operator by enonic.
the class MutationApi method xp7config.
private void xp7config(MutationRequest mt) {
// Collect old and new object
Xp7Config oldR = (Xp7Config) mt.getAdmissionReview().getRequest().getOldObject();
Xp7Config newR = (Xp7Config) mt.getAdmissionReview().getRequest().getObject();
// Create default status
Xp7ConfigStatus defStatus = new Xp7ConfigStatus().withMessage("Not loaded").withState(Xp7ConfigStatus.State.PENDING);
// 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;
}
// Ensure defaults
if (newR.getSpec() != null) {
patch(mt, false, "/spec/dataBase64", newR.getSpec().getDataBase64(), false);
patch(mt, false, "/spec/nodeGroup", newR.getSpec().getNodeGroup(), cfgStr("operator.charts.values.allNodesKey"));
}
if (op == AdmissionOperation.CREATE) {
// Ensure owner reference
ensureOwnerReference(mt);
}
}
Aggregations