use of io.strimzi.api.kafka.model.status.KafkaUserStatus in project strimzi-kafka-operator by strimzi.
the class KafkaUserOperator method createOrUpdate.
/**
* Creates or updates the user. The implementation
* should not assume that any resources are in any particular state (e.g. that the absence on
* one resource means that all resources need to be created).
*
* @param reconciliation Unique identification for the reconciliation
* @param resource KafkaUser resources with the desired user configuration.
* @return a Future
*/
@Override
protected Future<KafkaUserStatus> createOrUpdate(Reconciliation reconciliation, KafkaUser resource) {
KafkaUserModel user;
KafkaUserStatus userStatus = new KafkaUserStatus();
try {
user = KafkaUserModel.fromCrd(resource, config.getSecretPrefix(), config.isAclsAdminApiSupported());
LOGGER.debugCr(reconciliation, "Updating User {} in namespace {}", reconciliation.name(), reconciliation.namespace());
} catch (Exception e) {
LOGGER.warnCr(reconciliation, e);
StatusUtils.setStatusConditionAndObservedGeneration(resource, userStatus, Future.failedFuture(e));
return Future.failedFuture(new ReconciliationException(userStatus, e));
}
Promise<KafkaUserStatus> handler = Promise.promise();
secretOperations.getAsync(reconciliation.namespace(), user.getSecretName()).compose(userSecret -> maybeGenerateCredentials(reconciliation, user, userSecret)).compose(ignore -> reconcileCredentialsQuotasAndAcls(reconciliation, user, userStatus)).onComplete(reconciliationResult -> {
StatusUtils.setStatusConditionAndObservedGeneration(resource, userStatus, reconciliationResult.mapEmpty());
userStatus.setUsername(user.getUserName());
if (reconciliationResult.succeeded()) {
handler.complete(userStatus);
} else {
handler.fail(new ReconciliationException(userStatus, reconciliationResult.cause()));
}
});
return handler.future();
}
Aggregations