Skip to content

Commit 1a66228

Browse files
committed
fix: provide primitive type setters for ConfigBuilder
Signed-off-by: Marc Nuri <[email protected]>
1 parent 37ee45b commit 1a66228

File tree

2 files changed

+167
-0
lines changed

2 files changed

+167
-0
lines changed

kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ConfigFluent.java

+67
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,71 @@ public void copyInstance(Config instance) {
8181
this.withFile(instance.getFile());
8282
}
8383
}
84+
85+
// Fix #https://github.com/fabric8io/kubernetes-client/issues/6249
86+
// Unboxed builder methods (should allow for the co-existience of <6.13.2 and 6.13.x)
87+
public A withTrustCerts(boolean trustCerts) {
88+
return this.withTrustCerts(Boolean.valueOf(trustCerts));
89+
}
90+
91+
public A withDisableHostnameVerification(boolean disableHostnameVerification) {
92+
return this.withDisableHostnameVerification(Boolean.valueOf(disableHostnameVerification));
93+
}
94+
95+
public A withWebsocketPingInterval(long websocketPingInterval) {
96+
return this.withWebsocketPingInterval(Long.valueOf(websocketPingInterval));
97+
}
98+
99+
public A withConnectionTimeout(int connectionTimeout) {
100+
return this.withConnectionTimeout(Integer.valueOf(connectionTimeout));
101+
}
102+
103+
public A withMaxConcurrentRequests(int maxConcurrentRequests) {
104+
return this.withMaxConcurrentRequests(Integer.valueOf(maxConcurrentRequests));
105+
}
106+
107+
public A withWatchReconnectInterval(int watchReconnectInterval) {
108+
return this.withWatchReconnectInterval(Integer.valueOf(watchReconnectInterval));
109+
}
110+
111+
public A withWatchReconnectLimit(int watchReconnectLimit) {
112+
return this.withWatchReconnectLimit(Integer.valueOf(watchReconnectLimit));
113+
}
114+
115+
public A withUploadRequestTimeout(int uploadRequestTimeout) {
116+
return this.withUploadRequestTimeout(Integer.valueOf(uploadRequestTimeout));
117+
}
118+
119+
public A withRequestRetryBackoffLimit(int requestRetryBackoffLimit) {
120+
return this.withRequestRetryBackoffLimit(Integer.valueOf(requestRetryBackoffLimit));
121+
}
122+
123+
public A withRequestRetryBackoffInterval(int requestRetryBackoffInterval) {
124+
return this.withRequestRetryBackoffInterval(Integer.valueOf(requestRetryBackoffInterval));
125+
}
126+
127+
public A withRequestTimeout(int requestTimeout) {
128+
return this.withRequestTimeout(Integer.valueOf(requestTimeout));
129+
}
130+
131+
public A withScaleTimeout(long scaleTimeout) {
132+
return this.withScaleTimeout(Long.valueOf(scaleTimeout));
133+
}
134+
135+
public A withLoggingInterval(int loggingInterval) {
136+
return this.withLoggingInterval(Integer.valueOf(loggingInterval));
137+
}
138+
139+
public A withHttp2Disable(boolean http2Disable) {
140+
return this.withHttp2Disable(Boolean.valueOf(http2Disable));
141+
}
142+
143+
public A withOnlyHttpWatches(boolean onlyHttpWatches) {
144+
return this.withOnlyHttpWatches(Boolean.valueOf(onlyHttpWatches));
145+
}
146+
147+
public A withAutoConfigure(boolean autoConfigure) {
148+
return this.withAutoConfigure(Boolean.valueOf(autoConfigure));
149+
}
150+
84151
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*
2+
* Copyright (C) 2015 Red Hat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.fabric8.kubernetes.client;
17+
18+
import org.junit.jupiter.api.Test;
19+
20+
import static org.assertj.core.api.Assertions.assertThat;
21+
22+
class ConfigBuilderTest {
23+
24+
@Test
25+
void withPrimitiveValues() {
26+
final ConfigBuilder configBuilder = new ConfigBuilder()
27+
.withAutoConfigure(false)
28+
.withTrustCerts(true)
29+
.withDisableHostnameVerification(true)
30+
.withWebsocketPingInterval(133701)
31+
.withConnectionTimeout(133702)
32+
.withMaxConcurrentRequests(133703)
33+
.withWatchReconnectInterval(133704)
34+
.withWatchReconnectLimit(133705)
35+
.withUploadRequestTimeout(133706)
36+
.withRequestRetryBackoffLimit(133707)
37+
.withRequestRetryBackoffInterval(133708)
38+
.withRequestTimeout(133709)
39+
.withScaleTimeout(133710)
40+
.withLoggingInterval(133711)
41+
.withHttp2Disable(true)
42+
.withOnlyHttpWatches(true);
43+
assertThat(configBuilder.build())
44+
.hasFieldOrPropertyWithValue("autoConfigure", Boolean.FALSE)
45+
.hasFieldOrPropertyWithValue("trustCerts", Boolean.TRUE)
46+
.hasFieldOrPropertyWithValue("disableHostnameVerification", Boolean.TRUE)
47+
.hasFieldOrPropertyWithValue("websocketPingInterval", 133701L)
48+
.hasFieldOrPropertyWithValue("connectionTimeout", 133702)
49+
.hasFieldOrPropertyWithValue("maxConcurrentRequests", 133703)
50+
.hasFieldOrPropertyWithValue("watchReconnectInterval", 133704)
51+
.hasFieldOrPropertyWithValue("watchReconnectLimit", 133705)
52+
.hasFieldOrPropertyWithValue("uploadRequestTimeout", 133706)
53+
.hasFieldOrPropertyWithValue("requestRetryBackoffLimit", 133707)
54+
.hasFieldOrPropertyWithValue("requestRetryBackoffInterval", 133708)
55+
.hasFieldOrPropertyWithValue("requestTimeout", 133709)
56+
.hasFieldOrPropertyWithValue("scaleTimeout", 133710L)
57+
.hasFieldOrPropertyWithValue("loggingInterval", 133711)
58+
.hasFieldOrPropertyWithValue("http2Disable", Boolean.TRUE)
59+
.hasFieldOrPropertyWithValue("onlyHttpWatches", Boolean.TRUE);
60+
}
61+
62+
@Test
63+
void withBoxedValues() {
64+
final ConfigBuilder configBuilder = new ConfigBuilder()
65+
.withAutoConfigure(Boolean.FALSE)
66+
.withTrustCerts(Boolean.TRUE)
67+
.withDisableHostnameVerification(Boolean.TRUE)
68+
.withWebsocketPingInterval(Long.valueOf(133701))
69+
.withConnectionTimeout(Integer.valueOf(133702))
70+
.withMaxConcurrentRequests(Integer.valueOf(133703))
71+
.withWatchReconnectInterval(Integer.valueOf(133704))
72+
.withWatchReconnectLimit(Integer.valueOf(133705))
73+
.withUploadRequestTimeout(Integer.valueOf(133706))
74+
.withRequestRetryBackoffLimit(Integer.valueOf(133707))
75+
.withRequestRetryBackoffInterval(Integer.valueOf(133708))
76+
.withRequestTimeout(Integer.valueOf(133709))
77+
.withScaleTimeout(Long.valueOf(133710))
78+
.withLoggingInterval(Integer.valueOf(133711))
79+
.withHttp2Disable(Boolean.TRUE)
80+
.withOnlyHttpWatches(Boolean.TRUE);
81+
assertThat(configBuilder.build())
82+
.hasFieldOrPropertyWithValue("autoConfigure", false)
83+
.hasFieldOrPropertyWithValue("trustCerts", true)
84+
.hasFieldOrPropertyWithValue("disableHostnameVerification", true)
85+
.hasFieldOrPropertyWithValue("websocketPingInterval", 133701L)
86+
.hasFieldOrPropertyWithValue("connectionTimeout", 133702)
87+
.hasFieldOrPropertyWithValue("maxConcurrentRequests", 133703)
88+
.hasFieldOrPropertyWithValue("watchReconnectInterval", 133704)
89+
.hasFieldOrPropertyWithValue("watchReconnectLimit", 133705)
90+
.hasFieldOrPropertyWithValue("uploadRequestTimeout", 133706)
91+
.hasFieldOrPropertyWithValue("requestRetryBackoffLimit", 133707)
92+
.hasFieldOrPropertyWithValue("requestRetryBackoffInterval", 133708)
93+
.hasFieldOrPropertyWithValue("requestTimeout", 133709)
94+
.hasFieldOrPropertyWithValue("scaleTimeout", 133710L)
95+
.hasFieldOrPropertyWithValue("loggingInterval", 133711)
96+
.hasFieldOrPropertyWithValue("http2Disable", true)
97+
.hasFieldOrPropertyWithValue("onlyHttpWatches", true);
98+
}
99+
100+
}

0 commit comments

Comments
 (0)