Skip to content

Commit 407e1b7

Browse files
committed
Add ApiClient in ClientBuilder
Since the ApiClient has another constructor: apiClient(OkHttpClient). It's useful to allowing user customize the argument. OkHttp also recommend user to reuse the client instance(to sharing the internal dispatchers and connection pool). Signed-off-by: iseki <[email protected]>
1 parent 23f5e4c commit 407e1b7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

util/src/main/java/io/kubernetes/client/util/ClientBuilder.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public class ClientBuilder {
7373
// time to refresh exec based credentials
7474
// TODO: Read the expiration from the credential itself
7575
private Duration execCredentialRefreshPeriod = null;
76+
private ApiClient apiClient = null;
7677

7778
/**
7879
* Creates an {@link ApiClient} by calling {@link #standard()} and {@link #build()}.
@@ -435,8 +436,17 @@ public ClientBuilder setKeyStorePassphrase(String keyStorePassphrase) {
435436
return this;
436437
}
437438

439+
public ApiClient getApiClient() {
440+
return this.apiClient;
441+
}
442+
443+
public ClientBuilder setApiClient(ApiClient apiClient) {
444+
this.apiClient = apiClient;
445+
return this;
446+
}
447+
438448
public ApiClient build() {
439-
final ApiClient client = new ApiClient();
449+
final ApiClient client = this.apiClient == null ? new ApiClient() : this.apiClient;
440450

441451
client.setHttpClient(
442452
client

0 commit comments

Comments
 (0)