use of lombok.extern.java.Log in project bundlebee by yupiik.
the class HttpKubeClient method init.
@PostConstruct
private void init() {
client = new DelegatingClient(doConfigure(HttpClient.newBuilder().executor(dontUseAtRuntime.executor().orElseGet(ForkJoinPool::commonPool))).build()) {
@Override
public <T> CompletableFuture<HttpResponse<T>> sendAsync(final HttpRequest request, final HttpResponse.BodyHandler<T> responseBodyHandler) {
final OnKubeRequest kubeRequest = new OnKubeRequest(request);
onKubeRequestEvent.fire(kubeRequest);
if (kubeRequest.getUserResponse() != null) {
return CompletableFuture.class.cast(kubeRequest.getUserResponse().toCompletableFuture());
}
if (kubeRequest.getUserRequest() != null) {
return doSendAsync(kubeRequest.getUserRequest(), responseBodyHandler);
}
return doSendAsync(request, responseBodyHandler);
}
private <T> CompletableFuture<HttpResponse<T>> doSendAsync(final HttpRequest request, final HttpResponse.BodyHandler<T> responseBodyHandler) {
return super.sendAsync(request, responseBodyHandler).whenCompleteAsync((r, t) -> {
}, client.executor().orElseGet(ForkJoinPool::commonPool));
}
};
if (dryRun) {
client = new LoggingClient(log, new DryRunClient(client, skipDryRunForGet));
} else if (verbose) {
client = new LoggingClient(log, client);
}
if (loadedKubeConfig == null || loadedKubeConfig.getClusters() == null || loadedKubeConfig.getClusters().isEmpty()) {
final var c = new KubeConfig.Cluster();
c.setServer(baseApi);
final var cluster = new KubeConfig.NamedCluster();
cluster.setName("default");
cluster.setCluster(c);
loadedKubeConfig = new KubeConfig();
loadedKubeConfig.setClusters(List.of(cluster));
}
}
Aggregations