|
15 | 15 | */
|
16 | 16 | package io.fabric8.kubernetes.client;
|
17 | 17 |
|
| 18 | +import com.fasterxml.jackson.annotation.JsonAnyGetter; |
| 19 | +import com.fasterxml.jackson.annotation.JsonAnySetter; |
| 20 | +import com.fasterxml.jackson.annotation.JsonIgnore; |
| 21 | +import com.fasterxml.jackson.annotation.JsonInclude; |
| 22 | +import io.fabric8.kubernetes.api.model.AuthProviderConfig; |
18 | 23 | import io.fabric8.kubernetes.api.model.NamedContext;
|
19 | 24 | import io.fabric8.kubernetes.client.http.TlsVersion;
|
20 | 25 | import io.sundr.builder.annotations.Buildable;
|
| 26 | +import lombok.Data; |
21 | 27 |
|
| 28 | +import java.util.HashMap; |
22 | 29 | import java.util.List;
|
23 | 30 | import java.util.Map;
|
24 | 31 |
|
25 | 32 | /**
|
26 |
| - * This class is necessary to be able to autogenerate a builder for the Config class using Sundrio while providing |
| 33 | + * |
| 34 | + * To add a new config option: |
| 35 | + * <li>add a field in this class. Adding getters / setters is optional |
| 36 | + * <li>add logic in the {@link Config} constructor to copy the field. Optionally add auto configuration logic. |
| 37 | + * <li>no other changes are typically necessary |
| 38 | + * |
| 39 | + * This class is necessary to be able to cleanly deserialize the config. |
| 40 | + * It is also used to autogenerate a builder for the Config class using Sundrio while providing |
27 | 41 | * specific behavior for the build() method.
|
28 | 42 | *
|
29 | 43 | * This way we can extend the default SundrioConfigBuilder, overriding the build method and enabling autoconfiguration only in
|
|
34 | 48 | * The end purpose is for users to actually use the builder to override the default values or autoconfigured ones
|
35 | 49 | * by providing their values through the builder withXxx accessors
|
36 | 50 | */
|
37 |
| -class SundrioConfig extends Config { |
38 |
| - @Buildable(builderPackage = "io.fabric8.kubernetes.api.builder", editableEnabled = false) |
39 |
| - public SundrioConfig(String masterUrl, String apiVersion, String namespace, Boolean trustCerts, |
40 |
| - Boolean disableHostnameVerification, |
41 |
| - String caCertFile, String caCertData, String clientCertFile, String clientCertData, String clientKeyFile, |
42 |
| - String clientKeyData, String clientKeyAlgo, String clientKeyPassphrase, String username, String password, |
43 |
| - String oauthToken, String autoOAuthToken, Integer watchReconnectInterval, Integer watchReconnectLimit, |
44 |
| - Integer connectionTimeout, |
45 |
| - Integer requestTimeout, |
46 |
| - Long scaleTimeout, Integer loggingInterval, Integer maxConcurrentRequests, Integer maxConcurrentRequestsPerHost, |
47 |
| - Boolean http2Disable, String httpProxy, String httpsProxy, String[] noProxy, |
48 |
| - String userAgent, TlsVersion[] tlsVersions, Long websocketPingInterval, String proxyUsername, |
49 |
| - String proxyPassword, String trustStoreFile, String trustStorePassphrase, String keyStoreFile, String keyStorePassphrase, |
50 |
| - String impersonateUsername, String[] impersonateGroups, Map<String, List<String>> impersonateExtras, |
51 |
| - OAuthTokenProvider oauthTokenProvider, Map<String, String> customHeaders, Integer requestRetryBackoffLimit, |
52 |
| - Integer requestRetryBackoffInterval, Integer uploadRequestTimeout, Boolean onlyHttpWatches, NamedContext currentContext, |
53 |
| - List<NamedContext> contexts, Boolean autoConfigure) { |
54 |
| - super(masterUrl, apiVersion, namespace, trustCerts, disableHostnameVerification, caCertFile, caCertData, |
55 |
| - clientCertFile, clientCertData, clientKeyFile, clientKeyData, clientKeyAlgo, clientKeyPassphrase, username, |
56 |
| - password, oauthToken, autoOAuthToken, watchReconnectInterval, watchReconnectLimit, connectionTimeout, requestTimeout, |
57 |
| - scaleTimeout, loggingInterval, maxConcurrentRequests, maxConcurrentRequestsPerHost, http2Disable, |
58 |
| - httpProxy, httpsProxy, noProxy, userAgent, tlsVersions, websocketPingInterval, proxyUsername, proxyPassword, |
59 |
| - trustStoreFile, trustStorePassphrase, keyStoreFile, keyStorePassphrase, impersonateUsername, impersonateGroups, |
60 |
| - impersonateExtras, oauthTokenProvider, customHeaders, requestRetryBackoffLimit, requestRetryBackoffInterval, |
61 |
| - uploadRequestTimeout, onlyHttpWatches, currentContext, contexts, autoConfigure, true); |
| 51 | +@Buildable(lazyCollectionInitEnabled = false, lazyMapInitEnabled = false, builderPackage = "io.fabric8.kubernetes.api.builder", editableEnabled = false |
| 52 | +/* , ignore = "additionalProperties" */) |
| 53 | +@SuppressWarnings({ "LombokGetterMayBeUsed", "LombokSetterMayBeUsed" }) |
| 54 | +@JsonInclude(JsonInclude.Include.NON_NULL) |
| 55 | +@Data |
| 56 | +public class SundrioConfig { |
| 57 | + |
| 58 | + protected Boolean trustCerts; |
| 59 | + protected Boolean disableHostnameVerification; |
| 60 | + protected String masterUrl; |
| 61 | + protected String apiVersion; |
| 62 | + protected String namespace; |
| 63 | + protected Boolean defaultNamespace; |
| 64 | + protected String caCertFile; |
| 65 | + protected String caCertData; |
| 66 | + protected String clientCertFile; |
| 67 | + protected String clientCertData; |
| 68 | + protected String clientKeyFile; |
| 69 | + protected String clientKeyData; |
| 70 | + protected String clientKeyAlgo; |
| 71 | + protected String clientKeyPassphrase; |
| 72 | + protected String trustStoreFile; |
| 73 | + protected String trustStorePassphrase; |
| 74 | + protected String keyStoreFile; |
| 75 | + protected String keyStorePassphrase; |
| 76 | + protected AuthProviderConfig authProvider; |
| 77 | + protected String username; |
| 78 | + protected String password; |
| 79 | + protected volatile String oauthToken; |
| 80 | + @JsonIgnore |
| 81 | + protected volatile String autoOAuthToken; |
| 82 | + @JsonIgnore |
| 83 | + protected OAuthTokenProvider oauthTokenProvider; |
| 84 | + protected Long websocketPingInterval; |
| 85 | + protected Integer connectionTimeout; |
| 86 | + protected Integer maxConcurrentRequests; |
| 87 | + protected Integer maxConcurrentRequestsPerHost; |
| 88 | + |
| 89 | + protected List<NamedContext> contexts; |
| 90 | + protected NamedContext currentContext; |
| 91 | + |
| 92 | + protected Integer watchReconnectInterval; |
| 93 | + protected Integer watchReconnectLimit; |
| 94 | + protected Integer uploadRequestTimeout; |
| 95 | + protected Integer requestRetryBackoffLimit; |
| 96 | + protected Integer requestRetryBackoffInterval; |
| 97 | + protected Integer requestTimeout; |
| 98 | + protected Long scaleTimeout; |
| 99 | + protected Integer loggingInterval; |
| 100 | + protected String impersonateUsername; |
| 101 | + protected String[] impersonateGroups; |
| 102 | + protected Map<String, List<String>> impersonateExtras; |
| 103 | + |
| 104 | + protected Boolean http2Disable; |
| 105 | + protected String httpProxy; |
| 106 | + protected String httpsProxy; |
| 107 | + protected String proxyUsername; |
| 108 | + protected String proxyPassword; |
| 109 | + protected String[] noProxy; |
| 110 | + protected String userAgent; |
| 111 | + protected TlsVersion[] tlsVersions; |
| 112 | + |
| 113 | + protected Boolean onlyHttpWatches; |
| 114 | + |
| 115 | + /** |
| 116 | + * custom headers |
| 117 | + */ |
| 118 | + protected Map<String, String> customHeaders; |
| 119 | + |
| 120 | + protected Boolean autoConfigure; |
| 121 | + |
| 122 | + @JsonIgnore |
| 123 | + protected Map<String, Object> additionalProperties = new HashMap<>(); |
| 124 | + |
| 125 | + @JsonAnyGetter |
| 126 | + public Map<String, Object> getAdditionalProperties() { |
| 127 | + return this.additionalProperties; |
62 | 128 | }
|
| 129 | + |
| 130 | + @JsonAnySetter |
| 131 | + public void setAdditionalProperty(String name, Object value) { |
| 132 | + this.additionalProperties.put(name, value); |
| 133 | + } |
| 134 | + |
| 135 | + /* |
| 136 | + * Begin specific overrides for getters / setters |
| 137 | + * Only needed if changing the default signature, adding javadocs, etc. |
| 138 | + */ |
| 139 | + |
| 140 | + public void setImpersonateGroups(String... impersonateGroup) { |
| 141 | + this.impersonateGroups = impersonateGroup; |
| 142 | + } |
| 143 | + |
| 144 | + /** |
| 145 | + * Returns all the {@link NamedContext}s that exist in the kube config |
| 146 | + * |
| 147 | + * @return all the contexts |
| 148 | + * |
| 149 | + * @see NamedContext |
| 150 | + */ |
| 151 | + public List<NamedContext> getContexts() { |
| 152 | + return contexts; |
| 153 | + } |
| 154 | + |
| 155 | + /** |
| 156 | + * Returns the current context that's defined in the kube config. Returns {@code null} if there's none |
| 157 | + * |
| 158 | + * @return the current context |
| 159 | + * |
| 160 | + * @see NamedContext |
| 161 | + */ |
| 162 | + public NamedContext getCurrentContext() { |
| 163 | + return currentContext; |
| 164 | + } |
| 165 | + |
63 | 166 | }
|
0 commit comments