Skip to content

Commit 3a2cfc5

Browse files
committed
fix (kubernetes-client-api) : Config's autoConfigure should disable auto configuration
`Config`'s autoConfigure field should behave as per expectations. Signed-off-by: Rohan Kumar <[email protected]>
1 parent ad4fcaf commit 3a2cfc5

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#### Bugs
66
* Fix #6038: Support for Gradle configuration cache
77
* Fix #6110: VolumeSource (and other file mode fields) in Octal are correctly interpreted
8+
* Fix #6137: `ConfigBuilder.withAutoConfigure` is not working
89

910
#### Improvements
1011
* Fix #6008: removing the optional dependency on bouncy castle

kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/Config.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ public Config(String masterUrl, String apiVersion, String namespace, boolean tru
333333
userAgent, tlsVersions, websocketPingInterval, proxyUsername, proxyPassword,
334334
trustStoreFile, trustStorePassphrase, keyStoreFile, keyStorePassphrase, impersonateUsername, impersonateGroups,
335335
impersonateExtras, null, null, DEFAULT_REQUEST_RETRY_BACKOFFLIMIT, DEFAULT_REQUEST_RETRY_BACKOFFINTERVAL,
336-
DEFAULT_UPLOAD_REQUEST_TIMEOUT, false, null, Collections.emptyList());
336+
DEFAULT_UPLOAD_REQUEST_TIMEOUT, false, null, Collections.emptyList(), true);
337337
}
338338

339339
@Buildable(builderPackage = "io.fabric8.kubernetes.api.builder", editableEnabled = false)
@@ -349,7 +349,8 @@ public Config(String masterUrl, String apiVersion, String namespace, boolean tru
349349
String impersonateUsername, String[] impersonateGroups, Map<String, List<String>> impersonateExtras,
350350
OAuthTokenProvider oauthTokenProvider, Map<String, String> customHeaders, int requestRetryBackoffLimit,
351351
int requestRetryBackoffInterval, int uploadRequestTimeout, boolean onlyHttpWatches, NamedContext currentContext,
352-
List<NamedContext> contexts) {
352+
List<NamedContext> contexts, boolean autoConfigure) {
353+
this(autoConfigure);
353354
this.apiVersion = apiVersion;
354355
this.namespace = namespace;
355356
this.trustCerts = trustCerts;

kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/ConfigTest.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,39 @@ void testEmptyConfig() {
653653
.satisfies(e -> assertThat(e.getUserAgent()).isNotNull());
654654
}
655655

656+
@Test
657+
void testConfigWithAutoConfigureDisabled() {
658+
// Given
659+
// When
660+
Config emptyConfig = new ConfigBuilder().withAutoConfigure(false).build();
661+
662+
// Then
663+
assertThat(emptyConfig)
664+
.hasFieldOrPropertyWithValue("autoConfigure", false)
665+
.hasFieldOrPropertyWithValue("masterUrl", "https://kubernetes.default.svc/")
666+
.hasFieldOrPropertyWithValue("contexts", Collections.emptyList())
667+
.hasFieldOrPropertyWithValue("maxConcurrentRequests", 64)
668+
.hasFieldOrPropertyWithValue("maxConcurrentRequestsPerHost", 5)
669+
.hasFieldOrPropertyWithValue("trustCerts", false)
670+
.hasFieldOrPropertyWithValue("disableHostnameVerification", false)
671+
.hasFieldOrPropertyWithValue("clientKeyAlgo", null)
672+
.hasFieldOrPropertyWithValue("clientKeyPassphrase", "changeit")
673+
.hasFieldOrPropertyWithValue("watchReconnectInterval", 1000)
674+
.hasFieldOrPropertyWithValue("watchReconnectLimit", -1)
675+
.hasFieldOrPropertyWithValue("connectionTimeout", 10000)
676+
.hasFieldOrPropertyWithValue("requestTimeout", 10000)
677+
.hasFieldOrPropertyWithValue("scaleTimeout", 600000L)
678+
.hasFieldOrPropertyWithValue("loggingInterval", 20000)
679+
.hasFieldOrPropertyWithValue("websocketPingInterval", 30000L)
680+
.hasFieldOrPropertyWithValue("uploadRequestTimeout", 120000)
681+
.hasFieldOrPropertyWithValue("impersonateExtras", Collections.emptyMap())
682+
.hasFieldOrPropertyWithValue("http2Disable", false)
683+
.hasFieldOrPropertyWithValue("tlsVersions", new TlsVersion[] { TlsVersion.TLS_1_3, TlsVersion.TLS_1_2 })
684+
.satisfies(e -> assertThat(e.getCurrentContext()).isNull())
685+
.satisfies(e -> assertThat(e.getImpersonateGroups()).isEqualTo(new String[]{""}))
686+
.satisfies(e -> assertThat(e.getUserAgent()).isNotNull());
687+
}
688+
656689
private void assertConfig(Config config, boolean autoToken) {
657690
assertNotNull(config);
658691
assertTrue(config.isTrustCerts());

openshift-client-api/src/main/java/io/fabric8/openshift/client/OpenShiftConfig.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public OpenShiftConfig(String openShiftUrl, String oapiVersion, String masterUrl
8888
String[] impersonateGroups, Map<String, List<String>> impersonateExtras, OAuthTokenProvider oauthTokenProvider,
8989
Map<String, String> customHeaders, int requestRetryBackoffLimit, int requestRetryBackoffInterval,
9090
int uploadRequestTimeout, boolean onlyHttpWatches, long buildTimeout,
91-
boolean disableApiGroupCheck, NamedContext currentContext, List<NamedContext> contexts) {
91+
boolean disableApiGroupCheck, NamedContext currentContext, List<NamedContext> contexts, boolean autoConfigure) {
9292
super(masterUrl, apiVersion, namespace, trustCerts, disableHostnameVerification, caCertFile, caCertData,
9393
clientCertFile,
9494
clientCertData, clientKeyFile, clientKeyData, clientKeyAlgo, clientKeyPassphrase, username, password,
@@ -100,7 +100,7 @@ public OpenShiftConfig(String openShiftUrl, String oapiVersion, String masterUrl
100100
impersonateExtras, oauthTokenProvider, customHeaders,
101101
requestRetryBackoffLimit,
102102
requestRetryBackoffInterval,
103-
uploadRequestTimeout, onlyHttpWatches, currentContext, contexts);
103+
uploadRequestTimeout, onlyHttpWatches, currentContext, contexts, autoConfigure);
104104
this.setOapiVersion(oapiVersion);
105105
this.setBuildTimeout(buildTimeout);
106106
this.setDisableApiGroupCheck(disableApiGroupCheck);
@@ -144,7 +144,8 @@ public OpenShiftConfig(Config kubernetesConfig, String openShiftUrl, String oapi
144144
buildTimeout,
145145
false,
146146
kubernetesConfig.getCurrentContext(),
147-
kubernetesConfig.getContexts());
147+
kubernetesConfig.getContexts(),
148+
kubernetesConfig.getAutoConfigure());
148149
}
149150

150151
public static OpenShiftConfig wrap(Config config) {

0 commit comments

Comments
 (0)