Skip to content

Commit

Permalink
fix (kubernetes-client-api) : Config's autoConfigure should disab…
Browse files Browse the repository at this point in the history
…le auto configuration

`Config`'s autoConfigure field should behave as per expectations.

Signed-off-by: Rohan Kumar <[email protected]>
  • Loading branch information
rohanKanojia committed Jul 18, 2024
1 parent ad4fcaf commit c97e1e4
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#### Bugs
* Fix #6038: Support for Gradle configuration cache
* Fix #6110: VolumeSource (and other file mode fields) in Octal are correctly interpreted
* Fix #6137: `ConfigBuilder.withAutoConfigure` is not working

#### Improvements
* Fix #6008: removing the optional dependency on bouncy castle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public Config(String masterUrl, String apiVersion, String namespace, boolean tru
userAgent, tlsVersions, websocketPingInterval, proxyUsername, proxyPassword,
trustStoreFile, trustStorePassphrase, keyStoreFile, keyStorePassphrase, impersonateUsername, impersonateGroups,
impersonateExtras, null, null, DEFAULT_REQUEST_RETRY_BACKOFFLIMIT, DEFAULT_REQUEST_RETRY_BACKOFFINTERVAL,
DEFAULT_UPLOAD_REQUEST_TIMEOUT, false, null, Collections.emptyList());
DEFAULT_UPLOAD_REQUEST_TIMEOUT, false, null, Collections.emptyList(), true);
}

@Buildable(builderPackage = "io.fabric8.kubernetes.api.builder", editableEnabled = false)
Expand All @@ -349,7 +349,8 @@ public Config(String masterUrl, String apiVersion, String namespace, boolean tru
String impersonateUsername, String[] impersonateGroups, Map<String, List<String>> impersonateExtras,
OAuthTokenProvider oauthTokenProvider, Map<String, String> customHeaders, int requestRetryBackoffLimit,
int requestRetryBackoffInterval, int uploadRequestTimeout, boolean onlyHttpWatches, NamedContext currentContext,
List<NamedContext> contexts) {
List<NamedContext> contexts, boolean autoConfigure) {
this(autoConfigure);
this.apiVersion = apiVersion;
this.namespace = namespace;
this.trustCerts = trustCerts;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,39 @@ void testEmptyConfig() {
.satisfies(e -> assertThat(e.getUserAgent()).isNotNull());
}

@Test
void testConfigWithAutoConfigureDisabled() {
// Given
// When
Config emptyConfig = new ConfigBuilder().withAutoConfigure(false).build();

// Then
assertThat(emptyConfig)
.hasFieldOrPropertyWithValue("autoConfigure", false)
.hasFieldOrPropertyWithValue("masterUrl", "https://kubernetes.default.svc/")
.hasFieldOrPropertyWithValue("contexts", Collections.emptyList())
.hasFieldOrPropertyWithValue("maxConcurrentRequests", 64)
.hasFieldOrPropertyWithValue("maxConcurrentRequestsPerHost", 5)
.hasFieldOrPropertyWithValue("trustCerts", false)
.hasFieldOrPropertyWithValue("disableHostnameVerification", false)
.hasFieldOrPropertyWithValue("clientKeyAlgo", null)
.hasFieldOrPropertyWithValue("clientKeyPassphrase", "changeit")
.hasFieldOrPropertyWithValue("watchReconnectInterval", 1000)
.hasFieldOrPropertyWithValue("watchReconnectLimit", -1)
.hasFieldOrPropertyWithValue("connectionTimeout", 10000)
.hasFieldOrPropertyWithValue("requestTimeout", 10000)
.hasFieldOrPropertyWithValue("scaleTimeout", 600000L)
.hasFieldOrPropertyWithValue("loggingInterval", 20000)
.hasFieldOrPropertyWithValue("websocketPingInterval", 30000L)
.hasFieldOrPropertyWithValue("uploadRequestTimeout", 120000)
.hasFieldOrPropertyWithValue("impersonateExtras", Collections.emptyMap())
.hasFieldOrPropertyWithValue("http2Disable", false)
.hasFieldOrPropertyWithValue("tlsVersions", new TlsVersion[] { TlsVersion.TLS_1_3, TlsVersion.TLS_1_2 })
.satisfies(e -> assertThat(e.getCurrentContext()).isNull())
.satisfies(e -> assertThat(e.getImpersonateGroups()).isEqualTo(new String[] { "" }))
.satisfies(e -> assertThat(e.getUserAgent()).isNotNull());
}

private void assertConfig(Config config, boolean autoToken) {
assertNotNull(config);
assertTrue(config.isTrustCerts());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public OpenShiftConfig(String openShiftUrl, String oapiVersion, String masterUrl
String[] impersonateGroups, Map<String, List<String>> impersonateExtras, OAuthTokenProvider oauthTokenProvider,
Map<String, String> customHeaders, int requestRetryBackoffLimit, int requestRetryBackoffInterval,
int uploadRequestTimeout, boolean onlyHttpWatches, long buildTimeout,
boolean disableApiGroupCheck, NamedContext currentContext, List<NamedContext> contexts) {
boolean disableApiGroupCheck, NamedContext currentContext, List<NamedContext> contexts, boolean autoConfigure) {
super(masterUrl, apiVersion, namespace, trustCerts, disableHostnameVerification, caCertFile, caCertData,
clientCertFile,
clientCertData, clientKeyFile, clientKeyData, clientKeyAlgo, clientKeyPassphrase, username, password,
Expand All @@ -100,7 +100,7 @@ public OpenShiftConfig(String openShiftUrl, String oapiVersion, String masterUrl
impersonateExtras, oauthTokenProvider, customHeaders,
requestRetryBackoffLimit,
requestRetryBackoffInterval,
uploadRequestTimeout, onlyHttpWatches, currentContext, contexts);
uploadRequestTimeout, onlyHttpWatches, currentContext, contexts, autoConfigure);
this.setOapiVersion(oapiVersion);
this.setBuildTimeout(buildTimeout);
this.setDisableApiGroupCheck(disableApiGroupCheck);
Expand Down Expand Up @@ -144,7 +144,8 @@ public OpenShiftConfig(Config kubernetesConfig, String openShiftUrl, String oapi
buildTimeout,
false,
kubernetesConfig.getCurrentContext(),
kubernetesConfig.getContexts());
kubernetesConfig.getContexts(),
kubernetesConfig.getAutoConfigure());
}

public static OpenShiftConfig wrap(Config config) {
Expand Down

0 comments on commit c97e1e4

Please sign in to comment.