-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix (kubernetes-client-api) :
Config
's autoConfigure
should disab…
…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
1 parent
8d78ecf
commit d20f386
Showing
10 changed files
with
2,076 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
385 changes: 273 additions & 112 deletions
385
kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/Config.java
Large diffs are not rendered by default.
Oops, something went wrong.
89 changes: 89 additions & 0 deletions
89
kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ConfigBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Copyright (C) 2015 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
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(createEmptyConfigWithoutDefaults()); | ||
} | ||
|
||
public ConfigBuilder(ConfigFluent<?> fluent) { | ||
this(fluent, createEmptyConfigWithoutDefaults()); | ||
} | ||
|
||
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 createEmptyConfigWithoutDefaults() { | ||
Config config = Config.empty(); | ||
config.setAutoConfigure(!disableAutoConfig()); | ||
config.setMasterUrlRaw(null); | ||
config.setApiVersion(null); | ||
config.setClientKeyAlgo(null); | ||
config.setClientKeyPassphrase(null); | ||
config.setWebsocketPingInterval(null); | ||
config.setConnectionTimeout(null); | ||
config.setMaxConcurrentRequests(null); | ||
config.setMaxConcurrentRequestsPerHost(null); | ||
config.setContexts(null); | ||
config.setWatchReconnectInterval(null); | ||
config.setWatchReconnectLimit(null); | ||
config.setUploadRequestTimeout(null); | ||
config.setRequestRetryBackoffInterval(null); | ||
config.setRequestRetryBackoffLimit(null); | ||
config.setRequestTimeout(null); | ||
config.setScaleTimeout(null); | ||
config.setLoggingInterval(null); | ||
config.setUserAgent(null); | ||
config.setTlsVersions(null); | ||
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.getAutoConfigure()); | ||
buildable.setDefaultNamespace(fluent.isDefaultNamespace()); | ||
buildable.setAuthProvider(fluent.getAuthProvider()); | ||
buildable.setAuthProvider(fluent.getAuthProvider()); | ||
buildable.setFile(fluent.getFile()); | ||
return buildable; | ||
} | ||
} |
Oops, something went wrong.