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. We
need to make changes to ConfigBuilder and ConfigFluent in order to
achieve this.
- Move generated classes `ConfigBuilder` and `ConfigFluent` to `src/main/java`
  - `ConfigBuilder` would invoke `Config.empty()` in it's constructor
    instead of `new Config()` (this was enabling auto configuration)
  - add a boolean field to `ConfigFluent` in order to keep track of
    whether user has overridden auto configuration via builder or not.
- Make all fields in Config class use boxed types instead of primitive
  types so that we can distinguish whether they have been configured by
  user.

Signed-off-by: Rohan Kumar <[email protected]>
  • Loading branch information
rohanKanojia committed Aug 7, 2024
1 parent 8d78ecf commit d9d9c72
Show file tree
Hide file tree
Showing 9 changed files with 1,961 additions and 111 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Fix #6038: Support for Gradle configuration cache
* Fix #6110: VolumeSource (and other file mode fields) in Octal are correctly interpreted
* Fix #6215: Suppressing rejected execution exception for port forwarder
* Fix #6137: `ConfigBuilder.withAutoConfigure` is not working

#### Improvements
* Fix #6008: removing the optional dependency on bouncy castle
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package io.fabric8.kubernetes.client;

import io.fabric8.kubernetes.api.builder.VisitableBuilder;

import static io.fabric8.kubernetes.client.Config.disableAutoConfig;

public class ConfigBuilder extends ConfigFluent<ConfigBuilder> implements VisitableBuilder<Config, ConfigBuilder> {
public ConfigBuilder() {
this(emptyConfigWithAutoConfigure());
}

public ConfigBuilder(ConfigFluent<?> fluent) {
this(fluent, emptyConfigWithAutoConfigure());
}

public ConfigBuilder(ConfigFluent<?> fluent, Config instance) {
this.fluent = fluent;
fluent.copyInstance(instance);
}

public ConfigBuilder(Config instance) {
this.fluent = this;
this.copyInstance(instance);
}

ConfigFluent<?> fluent;

private static Config emptyConfigWithAutoConfigure() {
Config config = Config.empty();
config.setAutoConfigure(!disableAutoConfig());
return config;
}

public Config build() {
Config buildable = new Config(fluent.getMasterUrl(), fluent.getApiVersion(), fluent.getNamespace(), fluent.getTrustCerts(),
fluent.getDisableHostnameVerification(), fluent.getCaCertFile(), fluent.getCaCertData(), fluent.getClientCertFile(),
fluent.getClientCertData(), fluent.getClientKeyFile(), fluent.getClientKeyData(), fluent.getClientKeyAlgo(),
fluent.getClientKeyPassphrase(), fluent.getUsername(), fluent.getPassword(), fluent.getOauthToken(),
fluent.getAutoOAuthToken(), fluent.getWatchReconnectInterval(), fluent.getWatchReconnectLimit(),
fluent.getConnectionTimeout(), fluent.getRequestTimeout(), fluent.getScaleTimeout(), fluent.getLoggingInterval(),
fluent.getMaxConcurrentRequests(), fluent.getMaxConcurrentRequestsPerHost(), fluent.getHttp2Disable(),
fluent.getHttpProxy(), fluent.getHttpsProxy(), fluent.getNoProxy(), fluent.getUserAgent(), fluent.getTlsVersions(),
fluent.getWebsocketPingInterval(), fluent.getProxyUsername(), fluent.getProxyPassword(), fluent.getTrustStoreFile(),
fluent.getTrustStorePassphrase(), fluent.getKeyStoreFile(), fluent.getKeyStorePassphrase(),
fluent.getImpersonateUsername(), fluent.getImpersonateGroups(), fluent.getImpersonateExtras(),
fluent.getOauthTokenProvider(), fluent.getCustomHeaders(), fluent.getRequestRetryBackoffLimit(),
fluent.getRequestRetryBackoffInterval(), fluent.getUploadRequestTimeout(), fluent.getOnlyHttpWatches(),
fluent.getCurrentContext(), fluent.getContexts(), !fluent.hasAutoConfigureDisabledByUser());
buildable.setAuthProvider(fluent.getAuthProvider());
buildable.setFile(fluent.getFile());
return buildable;
}
}
Loading

0 comments on commit d9d9c72

Please sign in to comment.