From d9d9c722eaafb4737b4d955cea3ace89fbfbfd83 Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Thu, 25 Jul 2024 21:51:58 +0530 Subject: [PATCH] fix (kubernetes-client-api) : `Config`'s `autoConfigure` should disable 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 --- CHANGELOG.md | 1 + .../io/fabric8/kubernetes/client/Config.java | 338 +++- .../kubernetes/client/ConfigBuilder.java | 53 + .../kubernetes/client/ConfigFluent.java | 1607 +++++++++++++++++ .../ConfigDisableAutoConfigurationIT.java | 12 +- .../fabric8/kubernetes/client/ConfigTest.java | 2 +- .../DisableAutoConfigurationIT.java | 26 + .../openshift/client/OpenShiftConfig.java | 31 +- .../client/osgi/ManagedOpenShiftClient.java | 2 +- 9 files changed, 1961 insertions(+), 111 deletions(-) create mode 100644 kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ConfigBuilder.java create mode 100644 kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ConfigFluent.java diff --git a/CHANGELOG.md b/CHANGELOG.md index e13710c41e5..538695c223d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/Config.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/Config.java index f7abf6151ee..d0f19bc8dd5 100644 --- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/Config.java +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/Config.java @@ -37,7 +37,6 @@ import io.fabric8.kubernetes.client.utils.IOHelpers; import io.fabric8.kubernetes.client.utils.Serialization; import io.fabric8.kubernetes.client.utils.Utils; -import io.sundr.builder.annotations.Buildable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -57,6 +56,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.function.Predicate; import java.util.function.UnaryOperator; @@ -69,7 +69,7 @@ public class Config { private static final Logger LOGGER = LoggerFactory.getLogger(Config.class); /** - * Disables auto-configuration based on opinionated defaults in a {@link Config} object in the default constructor + * Disables auto-configuration based on opinionated defaults in a {@link Config} object in the Builder constructor */ public static final String KUBERNETES_DISABLE_AUTO_CONFIG_SYSTEM_PROPERTY = "kubernetes.disable.autoConfig"; public static final String KUBERNETES_MASTER_SYSTEM_PROPERTY = "kubernetes.master"; @@ -151,21 +151,25 @@ public class Config { private static final String ACCESS_TOKEN = "access-token"; private static final String ID_TOKEN = "id-token"; - - private boolean trustCerts; - private boolean disableHostnameVerification; - private String masterUrl = DEFAULT_MASTER_URL; - private String apiVersion = "v1"; + private static final TlsVersion[] DEFAULT_TLS_VERSIONS_LIST = new TlsVersion[] { TlsVersion.TLS_1_3, TlsVersion.TLS_1_2 }; + private static final int DEFAULT_WATCH_RECONNECT_INTERVAL = 1000; + private static final int DEFAULT_CONNECTION_TIMEOUT = 10 * 1000; + private static final String DEFAULT_USER_AGENT = "fabric8-kubernetes-client/" + Version.clientVersion(); + + private Boolean trustCerts; + private Boolean disableHostnameVerification; + private String masterUrl; + private String apiVersion; private String namespace; - private boolean defaultNamespace = true; + private Boolean defaultNamespace; private String caCertFile; private String caCertData; private String clientCertFile; private String clientCertData; private String clientKeyFile; private String clientKeyData; - private String clientKeyAlgo = "RSA"; - private String clientKeyPassphrase = "changeit"; + private String clientKeyAlgo; + private String clientKeyPassphrase; private String trustStoreFile; private String trustStorePassphrase; private String keyStoreFile; @@ -177,27 +181,27 @@ public class Config { @JsonIgnore private volatile String autoOAuthToken; private OAuthTokenProvider oauthTokenProvider; - private long websocketPingInterval = DEFAULT_WEBSOCKET_PING_INTERVAL; - private int connectionTimeout = 10 * 1000; - private int maxConcurrentRequests = DEFAULT_MAX_CONCURRENT_REQUESTS; - private int maxConcurrentRequestsPerHost = DEFAULT_MAX_CONCURRENT_REQUESTS_PER_HOST; + private Long websocketPingInterval; + private Integer connectionTimeout; + private Integer maxConcurrentRequests; + private Integer maxConcurrentRequestsPerHost; - private RequestConfig requestConfig = new RequestConfig(); + private final RequestConfig requestConfig; - private List contexts = new ArrayList<>(); + private List contexts; private NamedContext currentContext = null; /** * fields not used but needed for builder generation. */ - private int watchReconnectInterval = 1000; - private int watchReconnectLimit = -1; - private int uploadRequestTimeout = DEFAULT_UPLOAD_REQUEST_TIMEOUT; - private int requestRetryBackoffLimit; - private int requestRetryBackoffInterval; - private int requestTimeout = DEFAULT_REQUEST_TIMEOUT; - private long scaleTimeout = DEFAULT_SCALE_TIMEOUT; - private int loggingInterval = DEFAULT_LOGGING_INTERVAL; + private Integer watchReconnectInterval; + private Integer watchReconnectLimit; + private Integer uploadRequestTimeout; + private Integer requestRetryBackoffLimit; + private Integer requestRetryBackoffInterval; + private Integer requestTimeout; + private Long scaleTimeout; + private Integer loggingInterval; private String impersonateUsername; /** @@ -211,28 +215,28 @@ public class Config { * end of fields not used but needed for builder generation. */ - private boolean http2Disable; + private Boolean http2Disable; private String httpProxy; private String httpsProxy; private String proxyUsername; private String proxyPassword; private String[] noProxy; - private String userAgent = "fabric8-kubernetes-client/" + Version.clientVersion(); - private TlsVersion[] tlsVersions = new TlsVersion[] { TlsVersion.TLS_1_3, TlsVersion.TLS_1_2 }; + private String userAgent = DEFAULT_USER_AGENT; + private TlsVersion[] tlsVersions = DEFAULT_TLS_VERSIONS_LIST; - private boolean onlyHttpWatches; + private Boolean onlyHttpWatches; /** * custom headers */ private Map customHeaders = null; - private boolean autoConfigure; + private Boolean autoConfigure; private File file; @JsonIgnore - protected Map additionalProperties = new HashMap(); + protected Map additionalProperties = new HashMap<>(); /** * @deprecated use {@link #autoConfigure(String)} or {@link ConfigBuilder} instead @@ -242,14 +246,25 @@ public Config() { this(!disableAutoConfig()); } - private static boolean disableAutoConfig() { + static boolean disableAutoConfig() { return Utils.getSystemPropertyOrEnvVar(KUBERNETES_DISABLE_AUTO_CONFIG_SYSTEM_PROPERTY, false); } private Config(boolean autoConfigure) { - if (autoConfigure) { - autoConfigure(this, null); - } + this(null, null, null, null, null, + null, null, null, null, null, + null, null, null, null, null, + null, null, null, null, null, + null, null, null, null, + null, + null, null, null, null, + null, null, null, + null, + null, null, null, null, null, + null, null, null, + null, null, null, + null, null, false, null, + null, autoConfigure); } /** @@ -315,7 +330,7 @@ private static String ensureHttps(String masterUrl, Config config) { } @Deprecated - public Config(String masterUrl, String apiVersion, String namespace, boolean trustCerts, boolean disableHostnameVerification, + public Config(String masterUrl, String apiVersion, String namespace, Boolean trustCerts, boolean disableHostnameVerification, String caCertFile, String caCertData, String clientCertFile, String clientCertData, String clientKeyFile, String clientKeyData, String clientKeyAlgo, String clientKeyPassphrase, String username, String password, String oauthToken, String autoOAuthToken, int watchReconnectInterval, int watchReconnectLimit, int connectionTimeout, @@ -336,8 +351,8 @@ public Config(String masterUrl, String apiVersion, String namespace, boolean tru DEFAULT_UPLOAD_REQUEST_TIMEOUT, false, null, Collections.emptyList()); } - @Buildable(builderPackage = "io.fabric8.kubernetes.api.builder", editableEnabled = false) - public Config(String masterUrl, String apiVersion, String namespace, boolean trustCerts, boolean disableHostnameVerification, + @Deprecated + public Config(String masterUrl, String apiVersion, String namespace, Boolean trustCerts, boolean disableHostnameVerification, String caCertFile, String caCertData, String clientCertFile, String clientCertData, String clientKeyFile, String clientKeyData, String clientKeyAlgo, String clientKeyPassphrase, String username, String password, String oauthToken, String autoOAuthToken, int watchReconnectInterval, int watchReconnectLimit, int connectionTimeout, @@ -350,56 +365,201 @@ public Config(String masterUrl, String apiVersion, String namespace, boolean tru OAuthTokenProvider oauthTokenProvider, Map customHeaders, int requestRetryBackoffLimit, int requestRetryBackoffInterval, int uploadRequestTimeout, boolean onlyHttpWatches, NamedContext currentContext, List contexts) { - this.apiVersion = apiVersion; - this.namespace = namespace; - this.trustCerts = trustCerts; - this.disableHostnameVerification = disableHostnameVerification; - this.caCertFile = caCertFile; - this.caCertData = caCertData; - this.clientCertFile = clientCertFile; - this.clientCertData = clientCertData; - this.clientKeyFile = clientKeyFile; - this.clientKeyData = clientKeyData; - this.clientKeyAlgo = clientKeyAlgo; - this.clientKeyPassphrase = clientKeyPassphrase; - this.username = username; - this.password = password; - this.oauthToken = oauthToken; - this.websocketPingInterval = websocketPingInterval; - this.connectionTimeout = connectionTimeout; + this(masterUrl, apiVersion, namespace, trustCerts, disableHostnameVerification, caCertFile, caCertData, + clientCertFile, clientCertData, clientKeyFile, clientKeyData, clientKeyAlgo, clientKeyPassphrase, username, + password, oauthToken, autoOAuthToken, watchReconnectInterval, watchReconnectLimit, connectionTimeout, requestTimeout, + scaleTimeout, loggingInterval, maxConcurrentRequests, maxConcurrentRequestsPerHost, http2Disable, + httpProxy, httpsProxy, noProxy, userAgent, tlsVersions, websocketPingInterval, proxyUsername, proxyPassword, + trustStoreFile, trustStorePassphrase, keyStoreFile, keyStorePassphrase, impersonateUsername, impersonateGroups, + impersonateExtras, oauthTokenProvider, customHeaders, requestRetryBackoffLimit, requestRetryBackoffInterval, + uploadRequestTimeout, onlyHttpWatches, currentContext, contexts, false); + } - this.requestConfig = new RequestConfig(watchReconnectLimit, watchReconnectInterval, - requestTimeout, scaleTimeout, loggingInterval, - requestRetryBackoffLimit, requestRetryBackoffInterval, uploadRequestTimeout); - this.requestConfig.setImpersonateUsername(impersonateUsername); - this.requestConfig.setImpersonateGroups(impersonateGroups); - this.requestConfig.setImpersonateExtras(impersonateExtras); + public Config(String masterUrl, String apiVersion, String namespace, Boolean trustCerts, Boolean disableHostnameVerification, + String caCertFile, String caCertData, String clientCertFile, String clientCertData, String clientKeyFile, + String clientKeyData, String clientKeyAlgo, String clientKeyPassphrase, String username, String password, + String oauthToken, String autoOAuthToken, Integer watchReconnectInterval, Integer watchReconnectLimit, + Integer connectionTimeout, + Integer requestTimeout, + Long scaleTimeout, Integer loggingInterval, Integer maxConcurrentRequests, Integer maxConcurrentRequestsPerHost, + Boolean http2Disable, String httpProxy, String httpsProxy, String[] noProxy, + String userAgent, TlsVersion[] tlsVersions, Long websocketPingInterval, String proxyUsername, + String proxyPassword, String trustStoreFile, String trustStorePassphrase, String keyStoreFile, String keyStorePassphrase, + String impersonateUsername, String[] impersonateGroups, Map> impersonateExtras, + OAuthTokenProvider oauthTokenProvider, Map customHeaders, Integer requestRetryBackoffLimit, + Integer requestRetryBackoffInterval, Integer uploadRequestTimeout, Boolean onlyHttpWatches, NamedContext currentContext, + List contexts, Boolean autoConfigure) { + this.masterUrl = DEFAULT_MASTER_URL; + this.apiVersion = "v1"; + this.defaultNamespace = true; + this.clientKeyAlgo = "RSA"; + this.clientKeyPassphrase = "changeit"; + this.websocketPingInterval = DEFAULT_WEBSOCKET_PING_INTERVAL; + this.connectionTimeout = DEFAULT_CONNECTION_TIMEOUT; + this.maxConcurrentRequests = DEFAULT_MAX_CONCURRENT_REQUESTS; + this.maxConcurrentRequestsPerHost = DEFAULT_MAX_CONCURRENT_REQUESTS_PER_HOST; + this.contexts = new ArrayList<>(); + this.watchReconnectInterval = DEFAULT_WATCH_RECONNECT_INTERVAL; + this.watchReconnectLimit = -1; + this.uploadRequestTimeout = DEFAULT_UPLOAD_REQUEST_TIMEOUT; + this.requestRetryBackoffInterval = DEFAULT_REQUEST_RETRY_BACKOFFINTERVAL; + this.requestRetryBackoffLimit = DEFAULT_REQUEST_RETRY_BACKOFFLIMIT; + this.requestTimeout = DEFAULT_REQUEST_TIMEOUT; + this.scaleTimeout = DEFAULT_SCALE_TIMEOUT; + this.loggingInterval = DEFAULT_LOGGING_INTERVAL; + this.userAgent = "fabric8-kubernetes-client/" + Version.clientVersion(); + this.tlsVersions = new TlsVersion[] { TlsVersion.TLS_1_3, TlsVersion.TLS_1_2 }; + this.requestConfig = new RequestConfig(this.watchReconnectLimit, this.watchReconnectInterval, + this.requestTimeout, this.scaleTimeout, this.loggingInterval, + this.requestRetryBackoffLimit, this.requestRetryBackoffInterval, this.uploadRequestTimeout); + + if (Boolean.TRUE.equals(autoConfigure)) { + autoConfigure(this, null); + } + if (Utils.isNotNullOrEmpty(apiVersion) && !apiVersion.equals("v1")) { + this.apiVersion = apiVersion; + } + if (Utils.isNotNullOrEmpty(masterUrl) && !masterUrl.equals(ensureEndsWithSlash(ensureHttps(DEFAULT_MASTER_URL, this)))) { + this.masterUrl = masterUrl; + } + if (Utils.isNotNullOrEmpty(namespace)) { + this.namespace = namespace; + } + if (Boolean.TRUE.equals(trustCerts)) { + this.trustCerts = true; + } + if (Boolean.TRUE.equals(disableHostnameVerification)) { + this.disableHostnameVerification = true; + } + if (Utils.isNotNullOrEmpty(caCertFile)) { + this.caCertFile = caCertFile; + } + if (Utils.isNotNullOrEmpty(caCertData)) { + this.caCertData = caCertData; + } + if (Utils.isNotNullOrEmpty(clientCertFile)) { + this.clientCertFile = clientCertFile; + } + if (Utils.isNotNullOrEmpty(clientCertData)) { + this.clientCertData = clientCertData; + } + if (Utils.isNotNullOrEmpty(clientKeyFile)) { + this.clientKeyFile = clientKeyFile; + } + if (Utils.isNotNullOrEmpty(clientKeyData)) { + this.clientKeyData = clientKeyData; + } + if (Utils.isNotNullOrEmpty(clientKeyAlgo) && !clientKeyAlgo.equals("RSA")) { + this.clientKeyAlgo = clientKeyAlgo; + } + if (Utils.isNotNullOrEmpty(clientKeyPassphrase) && !clientKeyPassphrase.equals("changeit")) { + this.clientKeyPassphrase = clientKeyPassphrase; + } + if (Utils.isNotNullOrEmpty(username)) { + this.username = username; + } + if (Utils.isNotNullOrEmpty(password)) { + this.password = password; + } + if (Utils.isNotNullOrEmpty(oauthToken)) { + this.oauthToken = oauthToken; + } + if (websocketPingInterval != null && !websocketPingInterval.equals(DEFAULT_WEBSOCKET_PING_INTERVAL)) { + this.websocketPingInterval = websocketPingInterval; + } + if (connectionTimeout != null && !connectionTimeout.equals(DEFAULT_CONNECTION_TIMEOUT)) { + this.connectionTimeout = connectionTimeout; + } + if (watchReconnectLimit != null && watchReconnectLimit > 0) { + setWatchReconnectLimit(watchReconnectLimit); + } + if (watchReconnectInterval != null && watchReconnectInterval != DEFAULT_WATCH_RECONNECT_INTERVAL) { + setWatchReconnectInterval(watchReconnectInterval); + } + if (requestTimeout != null && requestTimeout != DEFAULT_REQUEST_TIMEOUT) { + setRequestTimeout(requestTimeout); + } + if (scaleTimeout != null && !scaleTimeout.equals(DEFAULT_SCALE_TIMEOUT)) { + setScaleTimeout(scaleTimeout); + } + if (loggingInterval != null && !loggingInterval.equals(DEFAULT_LOGGING_INTERVAL)) { + setLoggingInterval(loggingInterval); + } + if (requestRetryBackoffLimit != null && !requestRetryBackoffLimit.equals(DEFAULT_REQUEST_RETRY_BACKOFFLIMIT)) { + setRequestRetryBackoffLimit(requestRetryBackoffLimit); + } + if (requestRetryBackoffInterval != null && !requestRetryBackoffInterval.equals(DEFAULT_REQUEST_RETRY_BACKOFFINTERVAL)) { + setRequestRetryBackoffInterval(requestRetryBackoffInterval); + } + if (uploadRequestTimeout != null && !uploadRequestTimeout.equals(DEFAULT_UPLOAD_REQUEST_TIMEOUT)) { + setUploadRequestTimeout(uploadRequestTimeout); + } + if (Utils.isNotNullOrEmpty(impersonateUsername)) { + setImpersonateUsername(impersonateUsername); + } + if (Utils.isNotNullOrEmpty(impersonateGroups)) { + setImpersonateGroups(impersonateGroups); + } + if (Utils.isNotNullOrEmpty(impersonateExtras)) { + setImpersonateExtras(impersonateExtras); + } + if (http2Disable != null) { + this.http2Disable = http2Disable; + } + if (Utils.isNotNullOrEmpty(httpProxy)) { + this.httpProxy = httpProxy; + } + if (Utils.isNotNullOrEmpty(httpsProxy)) { + this.httpsProxy = httpsProxy; + } + if (Utils.isNotNullOrEmpty(noProxy)) { + this.noProxy = noProxy; + } + if (Utils.isNotNullOrEmpty(proxyUsername)) { + this.proxyUsername = proxyUsername; + } + if (Utils.isNotNullOrEmpty(proxyPassword)) { + this.proxyPassword = proxyPassword; + } + if (Utils.isNotNullOrEmpty(userAgent)) { + this.userAgent = userAgent; + } + if (tlsVersions != null && !Arrays.equals(tlsVersions, DEFAULT_TLS_VERSIONS_LIST)) { + this.tlsVersions = tlsVersions; + } + if (Utils.isNotNullOrEmpty(trustStoreFile)) { + this.trustStoreFile = trustStoreFile; + } + if (Utils.isNotNullOrEmpty(trustStorePassphrase)) { + this.trustStorePassphrase = trustStorePassphrase; + } + if (Utils.isNotNullOrEmpty(keyStoreFile)) { + this.keyStoreFile = keyStoreFile; + } + if (Utils.isNotNullOrEmpty(keyStorePassphrase)) { + this.keyStorePassphrase = keyStorePassphrase; + } + if (maxConcurrentRequests != null && !maxConcurrentRequests.equals(DEFAULT_MAX_CONCURRENT_REQUESTS)) { + this.maxConcurrentRequests = maxConcurrentRequests; + } + if (maxConcurrentRequestsPerHost != null && !maxConcurrentRequestsPerHost.equals(DEFAULT_MAX_CONCURRENT_REQUESTS_PER_HOST)) { + this.maxConcurrentRequestsPerHost = maxConcurrentRequestsPerHost; + } + if (Utils.isNotNullOrEmpty(autoOAuthToken)) { + this.autoOAuthToken = autoOAuthToken; + } + if (contexts != null && !contexts.isEmpty()) { + this.contexts = contexts; + } + if (Utils.isNotNull(currentContext)) { + this.currentContext = currentContext; + } - this.http2Disable = http2Disable; - this.httpProxy = httpProxy; - this.httpsProxy = httpsProxy; - this.noProxy = noProxy; - this.proxyUsername = proxyUsername; - this.proxyPassword = proxyPassword; - this.userAgent = userAgent; - this.tlsVersions = tlsVersions; - this.trustStoreFile = trustStoreFile; - this.trustStorePassphrase = trustStorePassphrase; - this.keyStoreFile = keyStoreFile; - this.keyStorePassphrase = keyStorePassphrase; + this.masterUrl = ensureEndsWithSlash(ensureHttps(this.masterUrl, this)); + this.autoConfigure = autoConfigure; this.oauthTokenProvider = oauthTokenProvider; this.customHeaders = customHeaders; - - //We need to keep this after ssl configuration & masterUrl - //We set the masterUrl because it's needed by ensureHttps - this.masterUrl = masterUrl; - this.masterUrl = ensureEndsWithSlash(ensureHttps(masterUrl, this)); - this.maxConcurrentRequests = maxConcurrentRequests; - this.maxConcurrentRequestsPerHost = maxConcurrentRequestsPerHost; - this.autoOAuthToken = autoOAuthToken; this.onlyHttpWatches = onlyHttpWatches; - this.contexts = contexts; - this.currentContext = currentContext; } public static void configFromSysPropsOrEnvVars(Config config) { @@ -443,7 +603,7 @@ public static void configFromSysPropsOrEnvVars(Config config) { String configuredImpersonateGroups = Utils.getSystemPropertyOrEnvVar(KUBERNETES_IMPERSONATE_GROUP, Arrays .stream(Optional.ofNullable(config.getImpersonateGroups()).orElse(new String[0])).collect(Collectors.joining(","))); - if (configuredImpersonateGroups != null) { + if (Utils.isNotNullOrEmpty(configuredImpersonateGroups)) { config.setImpersonateGroups(configuredImpersonateGroups.split(",")); } @@ -1149,7 +1309,7 @@ public void setMasterUrl(String masterUrl) { @JsonProperty("trustCerts") public boolean isTrustCerts() { - return trustCerts; + return Optional.ofNullable(trustCerts).orElse(false); } public void setTrustCerts(boolean trustCerts) { @@ -1158,7 +1318,7 @@ public void setTrustCerts(boolean trustCerts) { @JsonProperty("disableHostnameVerification") public boolean isDisableHostnameVerification() { - return disableHostnameVerification; + return Optional.ofNullable(disableHostnameVerification).orElse(false); } public void setDisableHostnameVerification(boolean disableHostnameVerification) { @@ -1252,7 +1412,7 @@ public void setLoggingInterval(int loggingInterval) { @JsonProperty("http2Disable") public boolean isHttp2Disable() { - return http2Disable; + return Optional.ofNullable(http2Disable).orElse(false); } public void setHttp2Disable(boolean http2Disable) { @@ -1297,7 +1457,7 @@ public void setNamespace(String namespace) { @JsonProperty("defaultNamespace") public boolean isDefaultNamespace() { - return defaultNamespace; + return Optional.ofNullable(defaultNamespace).orElse(true); } public void setDefaultNamespace(boolean defaultNamespace) { @@ -1423,7 +1583,7 @@ public void setCustomHeaders(Map customHeaders) { this.customHeaders = customHeaders; } - public boolean getAutoConfigure() { + public Boolean getAutoConfigure() { return autoConfigure; } @@ -1507,7 +1667,7 @@ public void setAutoOAuthToken(String autoOAuthToken) { } public boolean isOnlyHttpWatches() { - return onlyHttpWatches; + return Optional.ofNullable(onlyHttpWatches).orElse(false); } public void setOnlyHttpWatches(boolean onlyHttpWatches) { diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ConfigBuilder.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ConfigBuilder.java new file mode 100644 index 00000000000..9527d1c6735 --- /dev/null +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ConfigBuilder.java @@ -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 implements VisitableBuilder { + 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; + } +} diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ConfigFluent.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ConfigFluent.java new file mode 100644 index 00000000000..a4970c6ddf0 --- /dev/null +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ConfigFluent.java @@ -0,0 +1,1607 @@ +package io.fabric8.kubernetes.client; + +import io.fabric8.kubernetes.api.builder.BaseFluent; +import io.fabric8.kubernetes.api.model.AuthProviderConfig; +import io.fabric8.kubernetes.api.model.NamedContext; +import io.fabric8.kubernetes.client.http.TlsVersion; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Predicate; + +/** + * Generated + */ +@SuppressWarnings("unchecked") +public class ConfigFluent> extends BaseFluent { + public ConfigFluent() { + } + + public ConfigFluent(Config instance) { + this.copyInstance(instance); + } + + private Boolean trustCerts; + private Boolean disableHostnameVerification; + private String masterUrl; + private String apiVersion; + private String namespace; + private String caCertFile; + private String caCertData; + private String clientCertFile; + private String clientCertData; + private String clientKeyFile; + private String clientKeyData; + private String clientKeyAlgo; + private String clientKeyPassphrase; + private String trustStoreFile; + private String trustStorePassphrase; + private String keyStoreFile; + private String keyStorePassphrase; + private AuthProviderConfig authProvider; + private String username; + private String password; + private String oauthToken; + private String autoOAuthToken; + private OAuthTokenProvider oauthTokenProvider; + private Long websocketPingInterval; + private Integer connectionTimeout; + private Integer maxConcurrentRequests; + private Integer maxConcurrentRequestsPerHost; + private List contexts; + private NamedContext currentContext; + private Integer watchReconnectInterval; + private Integer watchReconnectLimit; + private Integer uploadRequestTimeout; + private Integer requestRetryBackoffLimit; + private Integer requestRetryBackoffInterval; + private Integer requestTimeout; + private Long scaleTimeout; + private Integer loggingInterval; + private String impersonateUsername; + private List impersonateGroups; + private Map> impersonateExtras; + private Boolean http2Disable; + private String httpProxy; + private String httpsProxy; + private String proxyUsername; + private String proxyPassword; + private List noProxy; + private String userAgent; + private List tlsVersions; + private Boolean onlyHttpWatches; + private Map customHeaders; + private Boolean autoConfigure; + private boolean autoConfigureDisabledByUser = false; + private File file; + + protected void copyInstance(Config instance) { + instance = (instance != null ? instance : new Config()); + if (instance != null) { + this.withMasterUrl(instance.getMasterUrl()); + this.withApiVersion(instance.getApiVersion()); + this.withNamespace(instance.getNamespace()); + this.withTrustCerts(instance.isTrustCerts()); + this.withDisableHostnameVerification(instance.isDisableHostnameVerification()); + this.withCaCertFile(instance.getCaCertFile()); + this.withCaCertData(instance.getCaCertData()); + this.withClientCertFile(instance.getClientCertFile()); + this.withClientCertData(instance.getClientCertData()); + this.withClientKeyFile(instance.getClientKeyFile()); + this.withClientKeyData(instance.getClientKeyData()); + this.withClientKeyAlgo(instance.getClientKeyAlgo()); + this.withClientKeyPassphrase(instance.getClientKeyPassphrase()); + this.withUsername(instance.getUsername()); + this.withPassword(instance.getPassword()); + this.withOauthToken(instance.getOauthToken()); + this.withAutoOAuthToken(instance.getAutoOAuthToken()); + this.withWatchReconnectInterval(instance.getWatchReconnectInterval()); + this.withWatchReconnectLimit(instance.getWatchReconnectLimit()); + this.withConnectionTimeout(instance.getConnectionTimeout()); + this.withRequestTimeout(instance.getRequestTimeout()); + this.withScaleTimeout(instance.getScaleTimeout()); + this.withLoggingInterval(instance.getLoggingInterval()); + this.withMaxConcurrentRequests(instance.getMaxConcurrentRequests()); + this.withMaxConcurrentRequestsPerHost(instance.getMaxConcurrentRequestsPerHost()); + this.withHttp2Disable(instance.isHttp2Disable()); + this.withHttpProxy(instance.getHttpProxy()); + this.withHttpsProxy(instance.getHttpsProxy()); + this.withNoProxy(instance.getNoProxy()); + this.withUserAgent(instance.getUserAgent()); + this.withTlsVersions(instance.getTlsVersions()); + this.withWebsocketPingInterval(instance.getWebsocketPingInterval()); + this.withProxyUsername(instance.getProxyUsername()); + this.withProxyPassword(instance.getProxyPassword()); + this.withTrustStoreFile(instance.getTrustStoreFile()); + this.withTrustStorePassphrase(instance.getTrustStorePassphrase()); + this.withKeyStoreFile(instance.getKeyStoreFile()); + this.withKeyStorePassphrase(instance.getKeyStorePassphrase()); + this.withImpersonateUsername(instance.getImpersonateUsername()); + this.withImpersonateGroups(instance.getImpersonateGroups()); + this.withImpersonateExtras(instance.getImpersonateExtras()); + this.withOauthTokenProvider(instance.getOauthTokenProvider()); + this.withCustomHeaders(instance.getCustomHeaders()); + this.withRequestRetryBackoffLimit(instance.getRequestRetryBackoffLimit()); + this.withRequestRetryBackoffInterval(instance.getRequestRetryBackoffInterval()); + this.withUploadRequestTimeout(instance.getUploadRequestTimeout()); + this.withOnlyHttpWatches(instance.isOnlyHttpWatches()); + this.withCurrentContext(instance.getCurrentContext()); + this.withContexts(instance.getContexts()); + this.withAutoConfigure(instance.getAutoConfigure()); + this.withAuthProvider(instance.getAuthProvider()); + this.withFile(instance.getFile()); + } + } + + public Boolean getTrustCerts() { + return this.trustCerts; + } + + public A withTrustCerts(Boolean trustCerts) { + this.trustCerts = trustCerts; + return (A) this; + } + + public boolean hasTrustCerts() { + return this.trustCerts != null; + } + + public Boolean getDisableHostnameVerification() { + return this.disableHostnameVerification; + } + + public A withDisableHostnameVerification(Boolean disableHostnameVerification) { + this.disableHostnameVerification = disableHostnameVerification; + return (A) this; + } + + public boolean hasDisableHostnameVerification() { + return this.disableHostnameVerification != null; + } + + public String getMasterUrl() { + return this.masterUrl; + } + + public A withMasterUrl(String masterUrl) { + this.masterUrl = masterUrl; + return (A) this; + } + + public boolean hasMasterUrl() { + return this.masterUrl != null; + } + + public String getApiVersion() { + return this.apiVersion; + } + + public A withApiVersion(String apiVersion) { + this.apiVersion = apiVersion; + return (A) this; + } + + public boolean hasApiVersion() { + return this.apiVersion != null; + } + + public String getNamespace() { + return this.namespace; + } + + public A withNamespace(String namespace) { + this.namespace = namespace; + return (A) this; + } + + public boolean hasNamespace() { + return this.namespace != null; + } + + public String getCaCertFile() { + return this.caCertFile; + } + + public A withCaCertFile(String caCertFile) { + this.caCertFile = caCertFile; + return (A) this; + } + + public boolean hasCaCertFile() { + return this.caCertFile != null; + } + + public String getCaCertData() { + return this.caCertData; + } + + public A withCaCertData(String caCertData) { + this.caCertData = caCertData; + return (A) this; + } + + public boolean hasCaCertData() { + return this.caCertData != null; + } + + public String getClientCertFile() { + return this.clientCertFile; + } + + public A withClientCertFile(String clientCertFile) { + this.clientCertFile = clientCertFile; + return (A) this; + } + + public boolean hasClientCertFile() { + return this.clientCertFile != null; + } + + public String getClientCertData() { + return this.clientCertData; + } + + public A withClientCertData(String clientCertData) { + this.clientCertData = clientCertData; + return (A) this; + } + + public boolean hasClientCertData() { + return this.clientCertData != null; + } + + public String getClientKeyFile() { + return this.clientKeyFile; + } + + public A withClientKeyFile(String clientKeyFile) { + this.clientKeyFile = clientKeyFile; + return (A) this; + } + + public boolean hasClientKeyFile() { + return this.clientKeyFile != null; + } + + public String getClientKeyData() { + return this.clientKeyData; + } + + public A withClientKeyData(String clientKeyData) { + this.clientKeyData = clientKeyData; + return (A) this; + } + + public boolean hasClientKeyData() { + return this.clientKeyData != null; + } + + public String getClientKeyAlgo() { + return this.clientKeyAlgo; + } + + public A withClientKeyAlgo(String clientKeyAlgo) { + this.clientKeyAlgo = clientKeyAlgo; + return (A) this; + } + + public boolean hasClientKeyAlgo() { + return this.clientKeyAlgo != null; + } + + public String getClientKeyPassphrase() { + return this.clientKeyPassphrase; + } + + public A withClientKeyPassphrase(String clientKeyPassphrase) { + this.clientKeyPassphrase = clientKeyPassphrase; + return (A) this; + } + + public boolean hasClientKeyPassphrase() { + return this.clientKeyPassphrase != null; + } + + public String getTrustStoreFile() { + return this.trustStoreFile; + } + + public A withTrustStoreFile(String trustStoreFile) { + this.trustStoreFile = trustStoreFile; + return (A) this; + } + + public boolean hasTrustStoreFile() { + return this.trustStoreFile != null; + } + + public String getTrustStorePassphrase() { + return this.trustStorePassphrase; + } + + public A withTrustStorePassphrase(String trustStorePassphrase) { + this.trustStorePassphrase = trustStorePassphrase; + return (A) this; + } + + public boolean hasTrustStorePassphrase() { + return this.trustStorePassphrase != null; + } + + public String getKeyStoreFile() { + return this.keyStoreFile; + } + + public A withKeyStoreFile(String keyStoreFile) { + this.keyStoreFile = keyStoreFile; + return (A) this; + } + + public boolean hasKeyStoreFile() { + return this.keyStoreFile != null; + } + + public String getKeyStorePassphrase() { + return this.keyStorePassphrase; + } + + public A withKeyStorePassphrase(String keyStorePassphrase) { + this.keyStorePassphrase = keyStorePassphrase; + return (A) this; + } + + public boolean hasKeyStorePassphrase() { + return this.keyStorePassphrase != null; + } + + public AuthProviderConfig getAuthProvider() { + return this.authProvider; + } + + public A withAuthProvider(AuthProviderConfig authProvider) { + this.authProvider = authProvider; + return (A) this; + } + + public boolean hasAuthProvider() { + return this.authProvider != null; + } + + public String getUsername() { + return this.username; + } + + public A withUsername(String username) { + this.username = username; + return (A) this; + } + + public boolean hasUsername() { + return this.username != null; + } + + public String getPassword() { + return this.password; + } + + public A withPassword(String password) { + this.password = password; + return (A) this; + } + + public boolean hasPassword() { + return this.password != null; + } + + public String getOauthToken() { + return this.oauthToken; + } + + public A withOauthToken(String oauthToken) { + this.oauthToken = oauthToken; + return (A) this; + } + + public boolean hasOauthToken() { + return this.oauthToken != null; + } + + public String getAutoOAuthToken() { + return this.autoOAuthToken; + } + + public A withAutoOAuthToken(String autoOAuthToken) { + this.autoOAuthToken = autoOAuthToken; + return (A) this; + } + + public boolean hasAutoOAuthToken() { + return this.autoOAuthToken != null; + } + + public OAuthTokenProvider getOauthTokenProvider() { + return this.oauthTokenProvider; + } + + public A withOauthTokenProvider(OAuthTokenProvider oauthTokenProvider) { + this.oauthTokenProvider = oauthTokenProvider; + return (A) this; + } + + public boolean hasOauthTokenProvider() { + return this.oauthTokenProvider != null; + } + + public Long getWebsocketPingInterval() { + return this.websocketPingInterval; + } + + public A withWebsocketPingInterval(Long websocketPingInterval) { + this.websocketPingInterval = websocketPingInterval; + return (A) this; + } + + public boolean hasWebsocketPingInterval() { + return this.websocketPingInterval != null; + } + + public Integer getConnectionTimeout() { + return this.connectionTimeout; + } + + public A withConnectionTimeout(Integer connectionTimeout) { + this.connectionTimeout = connectionTimeout; + return (A) this; + } + + public boolean hasConnectionTimeout() { + return this.connectionTimeout != null; + } + + public Integer getMaxConcurrentRequests() { + return this.maxConcurrentRequests; + } + + public A withMaxConcurrentRequests(Integer maxConcurrentRequests) { + this.maxConcurrentRequests = maxConcurrentRequests; + return (A) this; + } + + public boolean hasMaxConcurrentRequests() { + return this.maxConcurrentRequests != null; + } + + public Integer getMaxConcurrentRequestsPerHost() { + return this.maxConcurrentRequestsPerHost; + } + + public A withMaxConcurrentRequestsPerHost(Integer maxConcurrentRequestsPerHost) { + this.maxConcurrentRequestsPerHost = maxConcurrentRequestsPerHost; + return (A) this; + } + + public boolean hasMaxConcurrentRequestsPerHost() { + return this.maxConcurrentRequestsPerHost != null; + } + + public A addToContexts(int index, NamedContext item) { + if (this.contexts == null) { + this.contexts = new ArrayList(); + } + this.contexts.add(index, item); + return (A) this; + } + + public A setToContexts(int index, NamedContext item) { + if (this.contexts == null) { + this.contexts = new ArrayList(); + } + this.contexts.set(index, item); + return (A) this; + } + + public A addToContexts(io.fabric8.kubernetes.api.model.NamedContext... items) { + if (this.contexts == null) { + this.contexts = new ArrayList(); + } + for (NamedContext item : items) { + this.contexts.add(item); + } + return (A) this; + } + + public A addAllToContexts(Collection items) { + if (this.contexts == null) { + this.contexts = new ArrayList(); + } + for (NamedContext item : items) { + this.contexts.add(item); + } + return (A) this; + } + + public A removeFromContexts(io.fabric8.kubernetes.api.model.NamedContext... items) { + if (this.contexts == null) + return (A) this; + for (NamedContext item : items) { + this.contexts.remove(item); + } + return (A) this; + } + + public A removeAllFromContexts(Collection items) { + if (this.contexts == null) + return (A) this; + for (NamedContext item : items) { + this.contexts.remove(item); + } + return (A) this; + } + + public List getContexts() { + return this.contexts; + } + + public NamedContext getContext(int index) { + return this.contexts.get(index); + } + + public NamedContext getFirstContext() { + return this.contexts.get(0); + } + + public NamedContext getLastContext() { + return this.contexts.get(contexts.size() - 1); + } + + public NamedContext getMatchingContext(Predicate predicate) { + for (NamedContext item : contexts) { + if (predicate.test(item)) { + return item; + } + } + return null; + } + + public boolean hasMatchingContext(Predicate predicate) { + for (NamedContext item : contexts) { + if (predicate.test(item)) { + return true; + } + } + return false; + } + + public A withContexts(List contexts) { + if (contexts != null) { + this.contexts = new ArrayList(); + for (NamedContext item : contexts) { + this.addToContexts(item); + } + } else { + this.contexts = null; + } + return (A) this; + } + + public A withContexts(io.fabric8.kubernetes.api.model.NamedContext... contexts) { + if (this.contexts != null) { + this.contexts.clear(); + _visitables.remove("contexts"); + } + if (contexts != null) { + for (NamedContext item : contexts) { + this.addToContexts(item); + } + } + return (A) this; + } + + public boolean hasContexts() { + return this.contexts != null && !this.contexts.isEmpty(); + } + + public NamedContext getCurrentContext() { + return this.currentContext; + } + + public A withCurrentContext(NamedContext currentContext) { + this.currentContext = currentContext; + return (A) this; + } + + public boolean hasCurrentContext() { + return this.currentContext != null; + } + + public Integer getWatchReconnectInterval() { + return this.watchReconnectInterval; + } + + public A withWatchReconnectInterval(Integer watchReconnectInterval) { + this.watchReconnectInterval = watchReconnectInterval; + return (A) this; + } + + public boolean hasWatchReconnectInterval() { + return this.watchReconnectInterval != null; + } + + public Integer getWatchReconnectLimit() { + return this.watchReconnectLimit; + } + + public A withWatchReconnectLimit(Integer watchReconnectLimit) { + this.watchReconnectLimit = watchReconnectLimit; + return (A) this; + } + + public boolean hasWatchReconnectLimit() { + return this.watchReconnectLimit != null; + } + + public Integer getUploadRequestTimeout() { + return this.uploadRequestTimeout; + } + + public A withUploadRequestTimeout(Integer uploadRequestTimeout) { + this.uploadRequestTimeout = uploadRequestTimeout; + return (A) this; + } + + public boolean hasUploadRequestTimeout() { + return this.uploadRequestTimeout != null; + } + + public Integer getRequestRetryBackoffLimit() { + return this.requestRetryBackoffLimit; + } + + public A withRequestRetryBackoffLimit(Integer requestRetryBackoffLimit) { + this.requestRetryBackoffLimit = requestRetryBackoffLimit; + return (A) this; + } + + public boolean hasRequestRetryBackoffLimit() { + return this.requestRetryBackoffLimit != null; + } + + public Integer getRequestRetryBackoffInterval() { + return this.requestRetryBackoffInterval; + } + + public A withRequestRetryBackoffInterval(Integer requestRetryBackoffInterval) { + this.requestRetryBackoffInterval = requestRetryBackoffInterval; + return (A) this; + } + + public boolean hasRequestRetryBackoffInterval() { + return this.requestRetryBackoffInterval != null; + } + + public Integer getRequestTimeout() { + return this.requestTimeout; + } + + public A withRequestTimeout(Integer requestTimeout) { + this.requestTimeout = requestTimeout; + return (A) this; + } + + public boolean hasRequestTimeout() { + return this.requestTimeout != null; + } + + public Long getScaleTimeout() { + return this.scaleTimeout; + } + + public A withScaleTimeout(Long scaleTimeout) { + this.scaleTimeout = scaleTimeout; + return (A) this; + } + + public boolean hasScaleTimeout() { + return this.scaleTimeout != null; + } + + public Integer getLoggingInterval() { + return this.loggingInterval; + } + + public A withLoggingInterval(Integer loggingInterval) { + this.loggingInterval = loggingInterval; + return (A) this; + } + + public boolean hasLoggingInterval() { + return this.loggingInterval != null; + } + + public String getImpersonateUsername() { + return this.impersonateUsername; + } + + public A withImpersonateUsername(String impersonateUsername) { + this.impersonateUsername = impersonateUsername; + return (A) this; + } + + public boolean hasImpersonateUsername() { + return this.impersonateUsername != null; + } + + public A withImpersonateGroups(java.lang.String... impersonateGroups) { + if (this.impersonateGroups != null) { + this.impersonateGroups.clear(); + _visitables.remove("impersonateGroups"); + } + if (impersonateGroups != null) { + for (String item : impersonateGroups) { + this.addToImpersonateGroups(item); + } + } + return (A) this; + } + + public String[] getImpersonateGroups() { + int size = impersonateGroups != null ? impersonateGroups.size() : 0; + ; + String[] result = new String[size]; + ; + if (size == 0) { + return result; + } + int index = 0; + ; + for (String item : impersonateGroups) { + result[index++] = item; + } + return result; + } + + public A addToImpersonateGroups(int index, String item) { + if (this.impersonateGroups == null) { + this.impersonateGroups = new ArrayList(); + } + this.impersonateGroups.add(index, item); + return (A) this; + } + + public A setToImpersonateGroups(int index, String item) { + if (this.impersonateGroups == null) { + this.impersonateGroups = new ArrayList(); + } + this.impersonateGroups.set(index, item); + return (A) this; + } + + public A addToImpersonateGroups(java.lang.String... items) { + if (this.impersonateGroups == null) { + this.impersonateGroups = new ArrayList(); + } + for (String item : items) { + this.impersonateGroups.add(item); + } + return (A) this; + } + + public A addAllToImpersonateGroups(Collection items) { + if (this.impersonateGroups == null) { + this.impersonateGroups = new ArrayList(); + } + for (String item : items) { + this.impersonateGroups.add(item); + } + return (A) this; + } + + public A removeFromImpersonateGroups(java.lang.String... items) { + if (this.impersonateGroups == null) + return (A) this; + for (String item : items) { + this.impersonateGroups.remove(item); + } + return (A) this; + } + + public A removeAllFromImpersonateGroups(Collection items) { + if (this.impersonateGroups == null) + return (A) this; + for (String item : items) { + this.impersonateGroups.remove(item); + } + return (A) this; + } + + public boolean hasImpersonateGroups() { + return this.impersonateGroups != null && !this.impersonateGroups.isEmpty(); + } + + public A addToImpersonateExtras(String key, List value) { + if (this.impersonateExtras == null && key != null && value != null) { + this.impersonateExtras = new LinkedHashMap(); + } + if (key != null && value != null) { + this.impersonateExtras.put(key, value); + } + return (A) this; + } + + public A addToImpersonateExtras(Map> map) { + if (this.impersonateExtras == null && map != null) { + this.impersonateExtras = new LinkedHashMap(); + } + if (map != null) { + this.impersonateExtras.putAll(map); + } + return (A) this; + } + + public A removeFromImpersonateExtras(String key) { + if (this.impersonateExtras == null) { + return (A) this; + } + if (key != null && this.impersonateExtras != null) { + this.impersonateExtras.remove(key); + } + return (A) this; + } + + public A removeFromImpersonateExtras(Map> map) { + if (this.impersonateExtras == null) { + return (A) this; + } + if (map != null) { + for (Object key : map.keySet()) { + if (this.impersonateExtras != null) { + this.impersonateExtras.remove(key); + } + } + } + return (A) this; + } + + public Map> getImpersonateExtras() { + return this.impersonateExtras; + } + + public A withImpersonateExtras(Map> impersonateExtras) { + if (impersonateExtras == null) { + this.impersonateExtras = null; + } else { + this.impersonateExtras = new LinkedHashMap(impersonateExtras); + } + return (A) this; + } + + public boolean hasImpersonateExtras() { + return this.impersonateExtras != null; + } + + public Boolean getHttp2Disable() { + return this.http2Disable; + } + + public A withHttp2Disable(Boolean http2Disable) { + this.http2Disable = http2Disable; + return (A) this; + } + + public boolean hasHttp2Disable() { + return this.http2Disable != null; + } + + public String getHttpProxy() { + return this.httpProxy; + } + + public A withHttpProxy(String httpProxy) { + this.httpProxy = httpProxy; + return (A) this; + } + + public boolean hasHttpProxy() { + return this.httpProxy != null; + } + + public String getHttpsProxy() { + return this.httpsProxy; + } + + public A withHttpsProxy(String httpsProxy) { + this.httpsProxy = httpsProxy; + return (A) this; + } + + public boolean hasHttpsProxy() { + return this.httpsProxy != null; + } + + public String getProxyUsername() { + return this.proxyUsername; + } + + public A withProxyUsername(String proxyUsername) { + this.proxyUsername = proxyUsername; + return (A) this; + } + + public boolean hasProxyUsername() { + return this.proxyUsername != null; + } + + public String getProxyPassword() { + return this.proxyPassword; + } + + public A withProxyPassword(String proxyPassword) { + this.proxyPassword = proxyPassword; + return (A) this; + } + + public boolean hasProxyPassword() { + return this.proxyPassword != null; + } + + public A withNoProxy(java.lang.String... noProxy) { + if (this.noProxy != null) { + this.noProxy.clear(); + _visitables.remove("noProxy"); + } + if (noProxy != null) { + for (String item : noProxy) { + this.addToNoProxy(item); + } + } + return (A) this; + } + + public String[] getNoProxy() { + int size = noProxy != null ? noProxy.size() : 0; + ; + String[] result = new String[size]; + ; + if (size == 0) { + return result; + } + int index = 0; + ; + for (String item : noProxy) { + result[index++] = item; + } + return result; + } + + public A addToNoProxy(int index, String item) { + if (this.noProxy == null) { + this.noProxy = new ArrayList(); + } + this.noProxy.add(index, item); + return (A) this; + } + + public A setToNoProxy(int index, String item) { + if (this.noProxy == null) { + this.noProxy = new ArrayList(); + } + this.noProxy.set(index, item); + return (A) this; + } + + public A addToNoProxy(java.lang.String... items) { + if (this.noProxy == null) { + this.noProxy = new ArrayList(); + } + for (String item : items) { + this.noProxy.add(item); + } + return (A) this; + } + + public A addAllToNoProxy(Collection items) { + if (this.noProxy == null) { + this.noProxy = new ArrayList(); + } + for (String item : items) { + this.noProxy.add(item); + } + return (A) this; + } + + public A removeFromNoProxy(java.lang.String... items) { + if (this.noProxy == null) + return (A) this; + for (String item : items) { + this.noProxy.remove(item); + } + return (A) this; + } + + public A removeAllFromNoProxy(Collection items) { + if (this.noProxy == null) + return (A) this; + for (String item : items) { + this.noProxy.remove(item); + } + return (A) this; + } + + public boolean hasNoProxy() { + return this.noProxy != null && !this.noProxy.isEmpty(); + } + + public String getUserAgent() { + return this.userAgent; + } + + public A withUserAgent(String userAgent) { + this.userAgent = userAgent; + return (A) this; + } + + public boolean hasUserAgent() { + return this.userAgent != null; + } + + public A withTlsVersions(io.fabric8.kubernetes.client.http.TlsVersion... tlsVersions) { + if (this.tlsVersions != null) { + this.tlsVersions.clear(); + _visitables.remove("tlsVersions"); + } + if (tlsVersions != null) { + for (TlsVersion item : tlsVersions) { + this.addToTlsVersions(item); + } + } + return (A) this; + } + + public TlsVersion[] getTlsVersions() { + int size = tlsVersions != null ? tlsVersions.size() : 0; + ; + TlsVersion[] result = new TlsVersion[size]; + ; + if (size == 0) { + return result; + } + int index = 0; + ; + for (TlsVersion item : tlsVersions) { + result[index++] = item; + } + return result; + } + + public A addToTlsVersions(int index, TlsVersion item) { + if (this.tlsVersions == null) { + this.tlsVersions = new ArrayList(); + } + this.tlsVersions.add(index, item); + return (A) this; + } + + public A setToTlsVersions(int index, TlsVersion item) { + if (this.tlsVersions == null) { + this.tlsVersions = new ArrayList(); + } + this.tlsVersions.set(index, item); + return (A) this; + } + + public A addToTlsVersions(io.fabric8.kubernetes.client.http.TlsVersion... items) { + if (this.tlsVersions == null) { + this.tlsVersions = new ArrayList(); + } + for (TlsVersion item : items) { + this.tlsVersions.add(item); + } + return (A) this; + } + + public A addAllToTlsVersions(Collection items) { + if (this.tlsVersions == null) { + this.tlsVersions = new ArrayList(); + } + for (TlsVersion item : items) { + this.tlsVersions.add(item); + } + return (A) this; + } + + public A removeFromTlsVersions(io.fabric8.kubernetes.client.http.TlsVersion... items) { + if (this.tlsVersions == null) + return (A) this; + for (TlsVersion item : items) { + this.tlsVersions.remove(item); + } + return (A) this; + } + + public A removeAllFromTlsVersions(Collection items) { + if (this.tlsVersions == null) + return (A) this; + for (TlsVersion item : items) { + this.tlsVersions.remove(item); + } + return (A) this; + } + + public boolean hasTlsVersions() { + return this.tlsVersions != null && !this.tlsVersions.isEmpty(); + } + + public Boolean getOnlyHttpWatches() { + return this.onlyHttpWatches; + } + + public A withOnlyHttpWatches(Boolean onlyHttpWatches) { + this.onlyHttpWatches = onlyHttpWatches; + return (A) this; + } + + public boolean hasOnlyHttpWatches() { + return this.onlyHttpWatches != null; + } + + public A addToCustomHeaders(String key, String value) { + if (this.customHeaders == null && key != null && value != null) { + this.customHeaders = new LinkedHashMap(); + } + if (key != null && value != null) { + this.customHeaders.put(key, value); + } + return (A) this; + } + + public A addToCustomHeaders(Map map) { + if (this.customHeaders == null && map != null) { + this.customHeaders = new LinkedHashMap(); + } + if (map != null) { + this.customHeaders.putAll(map); + } + return (A) this; + } + + public A removeFromCustomHeaders(String key) { + if (this.customHeaders == null) { + return (A) this; + } + if (key != null && this.customHeaders != null) { + this.customHeaders.remove(key); + } + return (A) this; + } + + public A removeFromCustomHeaders(Map map) { + if (this.customHeaders == null) { + return (A) this; + } + if (map != null) { + for (Object key : map.keySet()) { + if (this.customHeaders != null) { + this.customHeaders.remove(key); + } + } + } + return (A) this; + } + + public Map getCustomHeaders() { + return this.customHeaders; + } + + public A withCustomHeaders(Map customHeaders) { + if (customHeaders == null) { + this.customHeaders = null; + } else { + this.customHeaders = new LinkedHashMap(customHeaders); + } + return (A) this; + } + + public boolean hasCustomHeaders() { + return this.customHeaders != null; + } + + public Boolean getAutoConfigure() { + return this.autoConfigure; + } + + public A withAutoConfigure(Boolean autoConfigure) { + this.autoConfigure = autoConfigure; + if (Boolean.FALSE.equals(this.autoConfigure)) { + this.autoConfigureDisabledByUser = true; + } + return (A) this; + } + + public boolean hasAutoConfigure() { + return this.autoConfigure != null; + } + + public boolean hasAutoConfigureDisabledByUser() { + return this.autoConfigureDisabledByUser; + } + + public File getFile() { + return this.file; + } + + public A withFile(File file) { + this.file = file; + return (A) this; + } + + public boolean hasFile() { + return this.file != null; + } + + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + if (!super.equals(o)) + return false; + ConfigFluent that = (ConfigFluent) o; + if (!java.util.Objects.equals(trustCerts, that.trustCerts)) + return false; + if (!java.util.Objects.equals(disableHostnameVerification, that.disableHostnameVerification)) + return false; + if (!java.util.Objects.equals(masterUrl, that.masterUrl)) + return false; + if (!java.util.Objects.equals(apiVersion, that.apiVersion)) + return false; + if (!java.util.Objects.equals(namespace, that.namespace)) + return false; + if (!java.util.Objects.equals(caCertFile, that.caCertFile)) + return false; + if (!java.util.Objects.equals(caCertData, that.caCertData)) + return false; + if (!java.util.Objects.equals(clientCertFile, that.clientCertFile)) + return false; + if (!java.util.Objects.equals(clientCertData, that.clientCertData)) + return false; + if (!java.util.Objects.equals(clientKeyFile, that.clientKeyFile)) + return false; + if (!java.util.Objects.equals(clientKeyData, that.clientKeyData)) + return false; + if (!java.util.Objects.equals(clientKeyAlgo, that.clientKeyAlgo)) + return false; + if (!java.util.Objects.equals(clientKeyPassphrase, that.clientKeyPassphrase)) + return false; + if (!java.util.Objects.equals(trustStoreFile, that.trustStoreFile)) + return false; + if (!java.util.Objects.equals(trustStorePassphrase, that.trustStorePassphrase)) + return false; + if (!java.util.Objects.equals(keyStoreFile, that.keyStoreFile)) + return false; + if (!java.util.Objects.equals(keyStorePassphrase, that.keyStorePassphrase)) + return false; + if (!java.util.Objects.equals(authProvider, that.authProvider)) + return false; + if (!java.util.Objects.equals(username, that.username)) + return false; + if (!java.util.Objects.equals(password, that.password)) + return false; + if (!java.util.Objects.equals(oauthToken, that.oauthToken)) + return false; + if (!java.util.Objects.equals(autoOAuthToken, that.autoOAuthToken)) + return false; + if (!java.util.Objects.equals(oauthTokenProvider, that.oauthTokenProvider)) + return false; + if (!java.util.Objects.equals(websocketPingInterval, that.websocketPingInterval)) + return false; + if (!java.util.Objects.equals(connectionTimeout, that.connectionTimeout)) + return false; + if (!java.util.Objects.equals(maxConcurrentRequests, that.maxConcurrentRequests)) + return false; + if (!java.util.Objects.equals(maxConcurrentRequestsPerHost, that.maxConcurrentRequestsPerHost)) + return false; + if (!java.util.Objects.equals(contexts, that.contexts)) + return false; + if (!java.util.Objects.equals(currentContext, that.currentContext)) + return false; + if (!java.util.Objects.equals(watchReconnectInterval, that.watchReconnectInterval)) + return false; + if (!java.util.Objects.equals(watchReconnectLimit, that.watchReconnectLimit)) + return false; + if (!java.util.Objects.equals(uploadRequestTimeout, that.uploadRequestTimeout)) + return false; + if (!java.util.Objects.equals(requestRetryBackoffLimit, that.requestRetryBackoffLimit)) + return false; + if (!java.util.Objects.equals(requestRetryBackoffInterval, that.requestRetryBackoffInterval)) + return false; + if (!java.util.Objects.equals(requestTimeout, that.requestTimeout)) + return false; + if (!java.util.Objects.equals(scaleTimeout, that.scaleTimeout)) + return false; + if (!java.util.Objects.equals(loggingInterval, that.loggingInterval)) + return false; + if (!java.util.Objects.equals(impersonateUsername, that.impersonateUsername)) + return false; + if (!java.util.Objects.equals(impersonateGroups, that.impersonateGroups)) + return false; + if (!java.util.Objects.equals(impersonateExtras, that.impersonateExtras)) + return false; + if (!java.util.Objects.equals(http2Disable, that.http2Disable)) + return false; + if (!java.util.Objects.equals(httpProxy, that.httpProxy)) + return false; + if (!java.util.Objects.equals(httpsProxy, that.httpsProxy)) + return false; + if (!java.util.Objects.equals(proxyUsername, that.proxyUsername)) + return false; + if (!java.util.Objects.equals(proxyPassword, that.proxyPassword)) + return false; + if (!java.util.Objects.equals(noProxy, that.noProxy)) + return false; + if (!java.util.Objects.equals(userAgent, that.userAgent)) + return false; + if (!java.util.Objects.equals(tlsVersions, that.tlsVersions)) + return false; + if (!java.util.Objects.equals(onlyHttpWatches, that.onlyHttpWatches)) + return false; + if (!java.util.Objects.equals(customHeaders, that.customHeaders)) + return false; + if (!java.util.Objects.equals(autoConfigure, that.autoConfigure)) + return false; + if (!java.util.Objects.equals(file, that.file)) + return false; + return true; + } + + public int hashCode() { + return java.util.Objects.hash(trustCerts, disableHostnameVerification, masterUrl, apiVersion, namespace, caCertFile, + caCertData, clientCertFile, clientCertData, clientKeyFile, clientKeyData, clientKeyAlgo, clientKeyPassphrase, + trustStoreFile, trustStorePassphrase, keyStoreFile, keyStorePassphrase, authProvider, username, password, oauthToken, + autoOAuthToken, oauthTokenProvider, websocketPingInterval, connectionTimeout, maxConcurrentRequests, + maxConcurrentRequestsPerHost, contexts, currentContext, watchReconnectInterval, watchReconnectLimit, + uploadRequestTimeout, requestRetryBackoffLimit, requestRetryBackoffInterval, requestTimeout, scaleTimeout, + loggingInterval, impersonateUsername, impersonateGroups, impersonateExtras, http2Disable, httpProxy, httpsProxy, + proxyUsername, proxyPassword, noProxy, userAgent, tlsVersions, onlyHttpWatches, customHeaders, autoConfigure, file, + super.hashCode()); + } + + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (trustCerts != null) { + sb.append("trustCerts:"); + sb.append(trustCerts + ","); + } + if (disableHostnameVerification != null) { + sb.append("disableHostnameVerification:"); + sb.append(disableHostnameVerification + ","); + } + if (masterUrl != null) { + sb.append("masterUrl:"); + sb.append(masterUrl + ","); + } + if (apiVersion != null) { + sb.append("apiVersion:"); + sb.append(apiVersion + ","); + } + if (namespace != null) { + sb.append("namespace:"); + sb.append(namespace + ","); + } + if (caCertFile != null) { + sb.append("caCertFile:"); + sb.append(caCertFile + ","); + } + if (caCertData != null) { + sb.append("caCertData:"); + sb.append(caCertData + ","); + } + if (clientCertFile != null) { + sb.append("clientCertFile:"); + sb.append(clientCertFile + ","); + } + if (clientCertData != null) { + sb.append("clientCertData:"); + sb.append(clientCertData + ","); + } + if (clientKeyFile != null) { + sb.append("clientKeyFile:"); + sb.append(clientKeyFile + ","); + } + if (clientKeyData != null) { + sb.append("clientKeyData:"); + sb.append(clientKeyData + ","); + } + if (clientKeyAlgo != null) { + sb.append("clientKeyAlgo:"); + sb.append(clientKeyAlgo + ","); + } + if (clientKeyPassphrase != null) { + sb.append("clientKeyPassphrase:"); + sb.append(clientKeyPassphrase + ","); + } + if (trustStoreFile != null) { + sb.append("trustStoreFile:"); + sb.append(trustStoreFile + ","); + } + if (trustStorePassphrase != null) { + sb.append("trustStorePassphrase:"); + sb.append(trustStorePassphrase + ","); + } + if (keyStoreFile != null) { + sb.append("keyStoreFile:"); + sb.append(keyStoreFile + ","); + } + if (keyStorePassphrase != null) { + sb.append("keyStorePassphrase:"); + sb.append(keyStorePassphrase + ","); + } + if (authProvider != null) { + sb.append("authProvider:"); + sb.append(authProvider + ","); + } + if (username != null) { + sb.append("username:"); + sb.append(username + ","); + } + if (password != null) { + sb.append("password:"); + sb.append(password + ","); + } + if (oauthToken != null) { + sb.append("oauthToken:"); + sb.append(oauthToken + ","); + } + if (autoOAuthToken != null) { + sb.append("autoOAuthToken:"); + sb.append(autoOAuthToken + ","); + } + if (oauthTokenProvider != null) { + sb.append("oauthTokenProvider:"); + sb.append(oauthTokenProvider + ","); + } + if (websocketPingInterval != null) { + sb.append("websocketPingInterval:"); + sb.append(websocketPingInterval + ","); + } + if (connectionTimeout != null) { + sb.append("connectionTimeout:"); + sb.append(connectionTimeout + ","); + } + if (maxConcurrentRequests != null) { + sb.append("maxConcurrentRequests:"); + sb.append(maxConcurrentRequests + ","); + } + if (maxConcurrentRequestsPerHost != null) { + sb.append("maxConcurrentRequestsPerHost:"); + sb.append(maxConcurrentRequestsPerHost + ","); + } + if (contexts != null && !contexts.isEmpty()) { + sb.append("contexts:"); + sb.append(contexts + ","); + } + if (currentContext != null) { + sb.append("currentContext:"); + sb.append(currentContext + ","); + } + if (watchReconnectInterval != null) { + sb.append("watchReconnectInterval:"); + sb.append(watchReconnectInterval + ","); + } + if (watchReconnectLimit != null) { + sb.append("watchReconnectLimit:"); + sb.append(watchReconnectLimit + ","); + } + if (uploadRequestTimeout != null) { + sb.append("uploadRequestTimeout:"); + sb.append(uploadRequestTimeout + ","); + } + if (requestRetryBackoffLimit != null) { + sb.append("requestRetryBackoffLimit:"); + sb.append(requestRetryBackoffLimit + ","); + } + if (requestRetryBackoffInterval != null) { + sb.append("requestRetryBackoffInterval:"); + sb.append(requestRetryBackoffInterval + ","); + } + if (requestTimeout != null) { + sb.append("requestTimeout:"); + sb.append(requestTimeout + ","); + } + if (scaleTimeout != null) { + sb.append("scaleTimeout:"); + sb.append(scaleTimeout + ","); + } + if (loggingInterval != null) { + sb.append("loggingInterval:"); + sb.append(loggingInterval + ","); + } + if (impersonateUsername != null) { + sb.append("impersonateUsername:"); + sb.append(impersonateUsername + ","); + } + if (impersonateGroups != null && !impersonateGroups.isEmpty()) { + sb.append("impersonateGroups:"); + sb.append(impersonateGroups + ","); + } + if (impersonateExtras != null && !impersonateExtras.isEmpty()) { + sb.append("impersonateExtras:"); + sb.append(impersonateExtras + ","); + } + if (http2Disable != null) { + sb.append("http2Disable:"); + sb.append(http2Disable + ","); + } + if (httpProxy != null) { + sb.append("httpProxy:"); + sb.append(httpProxy + ","); + } + if (httpsProxy != null) { + sb.append("httpsProxy:"); + sb.append(httpsProxy + ","); + } + if (proxyUsername != null) { + sb.append("proxyUsername:"); + sb.append(proxyUsername + ","); + } + if (proxyPassword != null) { + sb.append("proxyPassword:"); + sb.append(proxyPassword + ","); + } + if (noProxy != null && !noProxy.isEmpty()) { + sb.append("noProxy:"); + sb.append(noProxy + ","); + } + if (userAgent != null) { + sb.append("userAgent:"); + sb.append(userAgent + ","); + } + if (tlsVersions != null && !tlsVersions.isEmpty()) { + sb.append("tlsVersions:"); + sb.append(tlsVersions + ","); + } + if (onlyHttpWatches != null) { + sb.append("onlyHttpWatches:"); + sb.append(onlyHttpWatches + ","); + } + if (customHeaders != null && !customHeaders.isEmpty()) { + sb.append("customHeaders:"); + sb.append(customHeaders + ","); + } + if (autoConfigure != null) { + sb.append("autoConfigure:"); + sb.append(autoConfigure + ","); + } + if (file != null) { + sb.append("file:"); + sb.append(file); + } + sb.append("}"); + return sb.toString(); + } + + public A withTrustCerts() { + return withTrustCerts(true); + } + + public A withDisableHostnameVerification() { + return withDisableHostnameVerification(true); + } + + public A withHttp2Disable() { + return withHttp2Disable(true); + } + + public A withOnlyHttpWatches() { + return withOnlyHttpWatches(true); + } + + public A withAutoConfigure() { + return withAutoConfigure(true); + } + +} diff --git a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/ConfigDisableAutoConfigurationIT.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/ConfigDisableAutoConfigurationIT.java index 21b35e17e79..36539191841 100644 --- a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/ConfigDisableAutoConfigurationIT.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/ConfigDisableAutoConfigurationIT.java @@ -21,7 +21,6 @@ import io.fabric8.kubernetes.client.utils.Utils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -112,7 +111,7 @@ void whenConfigDisabledViaPropertyAndUserProvidesConfigurationViaConfigBuilder_t .withWatchReconnectLimit(10) .withConnectionTimeout(1000) .withRequestTimeout(1000) - .withScaleTimeout(1000) + .withScaleTimeout(1000L) .withLoggingInterval(1000) .withWebsocketPingInterval(10000L) .withUploadRequestTimeout(1000) @@ -214,7 +213,7 @@ void whenConfigDisabledViaPropertyAndUserProvidesConfigurationViaConfigBuilder_t .withWatchReconnectLimit(10) .withConnectionTimeout(1000) .withRequestTimeout(1000) - .withScaleTimeout(1000) + .withScaleTimeout(1000L) .withLoggingInterval(1000) .withWebsocketPingInterval(10000L) .withUploadRequestTimeout(1000) @@ -314,7 +313,7 @@ void whenConfigDisabledViaPropertyAndUserProvidesConfigurationViaConfigBuilder_t .withWatchReconnectLimit(10) .withConnectionTimeout(1000) .withRequestTimeout(1000) - .withScaleTimeout(1000) + .withScaleTimeout(1000L) .withLoggingInterval(1000) .withWebsocketPingInterval(10000L) .withUploadRequestTimeout(1000) @@ -361,7 +360,6 @@ void tearDown() { } @Nested - @Disabled("https://github.com/fabric8io/kubernetes-client/issues/6137") @DisplayName("With autoConfigure(false) in ConfigBuilder") class AutoConfigDisabledViaBuilder { private ConfigBuilder configBuilder; @@ -431,7 +429,7 @@ void whenConfigDisabledViaPropertyAndUserProvidesConfigurationViaConfigBuilder_t .withWatchReconnectLimit(10) .withConnectionTimeout(1000) .withRequestTimeout(1000) - .withScaleTimeout(1000) + .withScaleTimeout(1000L) .withLoggingInterval(1000) .withWebsocketPingInterval(10000L) .withUploadRequestTimeout(1000) @@ -533,7 +531,7 @@ void whenConfigDisabledViaPropertyAndUserProvidesConfigurationViaConfigBuilder_t .withWatchReconnectLimit(10) .withConnectionTimeout(1000) .withRequestTimeout(1000) - .withScaleTimeout(1000) + .withScaleTimeout(1000L) .withLoggingInterval(1000) .withWebsocketPingInterval(10000L) .withUploadRequestTimeout(1000) diff --git a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/ConfigTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/ConfigTest.java index e81f6045744..ad069d389de 100644 --- a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/ConfigTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/ConfigTest.java @@ -953,7 +953,7 @@ void emptyConfig() { // Then assertThat(emptyConfig) - .hasFieldOrPropertyWithValue("masterUrl", "https://kubernetes.default.svc") + .hasFieldOrPropertyWithValue("masterUrl", "https://kubernetes.default.svc/") .hasFieldOrPropertyWithValue("contexts", Collections.emptyList()) .hasFieldOrPropertyWithValue("maxConcurrentRequests", 64) .hasFieldOrPropertyWithValue("maxConcurrentRequestsPerHost", 5) diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/DisableAutoConfigurationIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/DisableAutoConfigurationIT.java index 4afd7ef4a8e..cdbe8dcafc4 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/DisableAutoConfigurationIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/DisableAutoConfigurationIT.java @@ -31,6 +31,32 @@ class DisableAutoConfigurationIT { KubernetesClient client; + @Test + @DisplayName("with autoConfigure=false, then client should not load kubeconfig contents") + void givenConfigWithAutoConfigureDisabled_shouldNotLoadLocalKubeConfig() { + // Given + When + client = new KubernetesClientBuilder().withConfig(new ConfigBuilder() + .withAutoConfigure(false) + .withRequestRetryBackoffLimit(0) + .build()).build(); + + // Then + assertThat(client.getConfiguration()) + .hasFieldOrPropertyWithValue("namespace", null) + .hasFieldOrPropertyWithValue("masterUrl", "https://kubernetes.default.svc/") + .hasFieldOrPropertyWithValue("contexts", Collections.emptyList()) + .hasFieldOrPropertyWithValue("currentContext", null) + .hasFieldOrPropertyWithValue("username", null) + .hasFieldOrPropertyWithValue("clientCertFile", null) + .hasFieldOrPropertyWithValue("clientKeyFile", null) + .hasFieldOrPropertyWithValue("clientCertData", null) + .hasFieldOrPropertyWithValue("caCertFile", null) + .hasFieldOrPropertyWithValue("caCertData", null); + assertThatExceptionOfType(KubernetesClientException.class) + .isThrownBy(() -> client.pods().list()) + .withMessageContaining("Operation: [list] for kind: [Pod] with name: [null] in namespace: [null] failed."); + } + @Test @DisplayName("kubernetes.disable.autoConfig=true, then client should not load kubeconfig contents") void givenDisableAutoConfigPropertyTrue_shouldNotLoadLocalKubeConfig() { diff --git a/openshift-client-api/src/main/java/io/fabric8/openshift/client/OpenShiftConfig.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/OpenShiftConfig.java index a7562ad5683..59b9912319f 100644 --- a/openshift-client-api/src/main/java/io/fabric8/openshift/client/OpenShiftConfig.java +++ b/openshift-client-api/src/main/java/io/fabric8/openshift/client/OpenShiftConfig.java @@ -52,8 +52,8 @@ public class OpenShiftConfig extends Config { // dummy fields so that Builder is created correctly private String oapiVersion; private String openShiftUrl; - private long buildTimeout; - private boolean disableApiGroupCheck; //If group hasn't been explicitly set. + private Long buildTimeout; + private Boolean disableApiGroupCheck; //If group hasn't been explicitly set. //This is not meant to be used. This constructor is used only by the generated builder. OpenShiftConfig() { @@ -73,22 +73,22 @@ public OpenShiftConfig(Config kubernetesConfig, String openShiftUrl) { @Buildable(builderPackage = "io.fabric8.kubernetes.api.builder", editableEnabled = false, refs = { @BuildableReference(Config.class) }) public OpenShiftConfig(String openShiftUrl, String oapiVersion, String masterUrl, String apiVersion, String namespace, - boolean trustCerts, boolean disableHostnameVerification, String caCertFile, String caCertData, + Boolean trustCerts, Boolean disableHostnameVerification, String caCertFile, String caCertData, String clientCertFile, String clientCertData, String clientKeyFile, String clientKeyData, String clientKeyAlgo, String clientKeyPassphrase, - String username, String password, String oauthToken, String autoOAuthToken, int watchReconnectInterval, - int watchReconnectLimit, - int connectionTimeout, int requestTimeout, long scaleTimeout, int loggingInterval, - int maxConcurrentRequests, int maxConcurrentRequestsPerHost, boolean http2Disable, String httpProxy, + String username, String password, String oauthToken, String autoOAuthToken, Integer watchReconnectInterval, + Integer watchReconnectLimit, + Integer connectionTimeout, Integer requestTimeout, Long scaleTimeout, Integer loggingInterval, + Integer maxConcurrentRequests, Integer maxConcurrentRequestsPerHost, Boolean http2Disable, String httpProxy, String httpsProxy, String[] noProxy, String userAgent, TlsVersion[] tlsVersions, - long websocketPingInterval, String proxyUsername, String proxyPassword, String trustStoreFile, + Long websocketPingInterval, String proxyUsername, String proxyPassword, String trustStoreFile, String trustStorePassphrase, String keyStoreFile, String keyStorePassphrase, String impersonateUsername, String[] impersonateGroups, Map> impersonateExtras, OAuthTokenProvider oauthTokenProvider, - Map customHeaders, int requestRetryBackoffLimit, int requestRetryBackoffInterval, - int uploadRequestTimeout, boolean onlyHttpWatches, long buildTimeout, - boolean disableApiGroupCheck, NamedContext currentContext, List contexts) { + Map customHeaders, Integer requestRetryBackoffLimit, Integer requestRetryBackoffInterval, + Integer uploadRequestTimeout, Boolean onlyHttpWatches, Long buildTimeout, + Boolean disableApiGroupCheck, NamedContext currentContext, List contexts, Boolean autoConfigure) { super(masterUrl, apiVersion, namespace, trustCerts, disableHostnameVerification, caCertFile, caCertData, clientCertFile, clientCertData, clientKeyFile, clientKeyData, clientKeyAlgo, clientKeyPassphrase, username, password, @@ -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); @@ -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) { @@ -208,6 +209,10 @@ public boolean isDisableApiGroupCheck() { return Boolean.TRUE.equals(additionalProperties.get(DISABLE_API_GROUP_CHECK)); } + public boolean getDisableApiGroupCheck() { + return disableApiGroupCheck; + } + public void setDisableApiGroupCheck(boolean disableApiGroupCheck) { this.additionalProperties.put(DISABLE_API_GROUP_CHECK, disableApiGroupCheck); } diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/osgi/ManagedOpenShiftClient.java b/openshift-client/src/main/java/io/fabric8/openshift/client/osgi/ManagedOpenShiftClient.java index 73572207ae0..6ed35a139e4 100644 --- a/openshift-client/src/main/java/io/fabric8/openshift/client/osgi/ManagedOpenShiftClient.java +++ b/openshift-client/src/main/java/io/fabric8/openshift/client/osgi/ManagedOpenShiftClient.java @@ -131,7 +131,7 @@ public void activate(Map properties) { builder.withOpenShiftUrl(URLUtils.join(builder.getMasterUrl(), "oapi", builder.getOapiVersion())); } if (properties.containsKey(OPENSHIFT_BUILD_TIMEOUT_SYSTEM_PROPERTY)) { - builder.withBuildTimeout(Integer.parseInt((String) properties.get(OPENSHIFT_BUILD_TIMEOUT_SYSTEM_PROPERTY))); + builder.withBuildTimeout(Long.parseLong((String) properties.get(OPENSHIFT_BUILD_TIMEOUT_SYSTEM_PROPERTY))); } else { builder.withBuildTimeout(DEFAULT_BUILD_TIMEOUT); }