Skip to content

Commit 6f66a6c

Browse files
committed
fixes compile
Signed-off-by: yue9944882 <[email protected]>
1 parent b5ba6f0 commit 6f66a6c

File tree

6 files changed

+56
-55
lines changed

6 files changed

+56
-55
lines changed

examples/examples-release-15/src/main/java/io/kubernetes/client/examples/YamlExample.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import io.kubernetes.client.openapi.models.V1PodBuilder;
2323
import io.kubernetes.client.openapi.models.V1Service;
2424
import io.kubernetes.client.openapi.models.V1ServiceBuilder;
25-
import io.kubernetes.client.openapi.models.V1ServicePort;
26-
import io.kubernetes.client.openapi.models.V1ServiceSpec;
2725
import io.kubernetes.client.util.Config;
2826
import io.kubernetes.client.util.Yaml;
2927
import java.io.File;
@@ -63,10 +61,10 @@ public static void main(String[] args) throws IOException, ApiException, ClassNo
6361
.withName("aservice")
6462
.endMetadata()
6563
.withNewSpec()
66-
.withSessionAffinity(V1ServiceSpec.SessionAffinityEnum.CLIENTIP)
67-
.withType(V1ServiceSpec.TypeEnum.NODEPORT)
64+
.withSessionAffinity("ClientIP")
65+
.withType("NodePort")
6866
.addNewPort()
69-
.withProtocol(V1ServicePort.ProtocolEnum.TCP)
67+
.withProtocol("TCP")
7068
.withName("client")
7169
.withPort(8008)
7270
.withNodePort(8080)

extended/src/main/java/io/kubernetes/client/extended/kubectl/KubectlTaint.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,10 @@
1212
*/
1313
package io.kubernetes.client.extended.kubectl;
1414

15-
import static io.kubernetes.client.openapi.models.V1Taint.EffectEnum.NOEXECUTE;
16-
import static io.kubernetes.client.openapi.models.V1Taint.EffectEnum.NOSCHEDULE;
17-
import static io.kubernetes.client.openapi.models.V1Taint.EffectEnum.PREFERNOSCHEDULE;
18-
1915
import io.kubernetes.client.extended.kubectl.exception.KubectlException;
2016
import io.kubernetes.client.openapi.ApiException;
2117
import io.kubernetes.client.openapi.apis.CoreV1Api;
2218
import io.kubernetes.client.openapi.models.V1Node;
23-
import io.kubernetes.client.openapi.models.V1Taint;
2419
import io.kubernetes.client.util.taints.Taints;
2520
import io.kubernetes.client.util.taints.Taints.TaintsBuilder;
2621
import java.io.IOException;
@@ -89,15 +84,15 @@ private V1Node executeInternal() throws KubectlException, ApiException, IOExcept
8984
return v1.replaceNode(name, node, null, null, null, null);
9085
}
9186

92-
private V1Taint.EffectEnum makeEffect(String effect) throws KubectlException {
93-
if (effect.equals(NOSCHEDULE.toString())) {
94-
return NOSCHEDULE;
87+
private Taints.Effect makeEffect(String effect) throws KubectlException {
88+
if (effect.equals(Taints.Effect.NO_SCHEDULE.toString())) {
89+
return Taints.Effect.NO_SCHEDULE;
9590
}
96-
if (effect.equals(PREFERNOSCHEDULE.toString())) {
97-
return PREFERNOSCHEDULE;
91+
if (effect.equals(Taints.Effect.PREFER_NO_SCHEDULE.toString())) {
92+
return Taints.Effect.PREFER_NO_SCHEDULE;
9893
}
99-
if (effect.equals(NOEXECUTE.toString())) {
100-
return NOEXECUTE;
94+
if (effect.equals(Taints.Effect.NO_EXECUTE.toString())) {
95+
return Taints.Effect.NO_EXECUTE;
10196
}
10297
throw new KubectlException("Unknown effect: " + effect);
10398
}

util/src/main/java/io/kubernetes/client/util/CSRUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static void approve(ApiClient apiClient, String csrObjName) throws ApiExc
6868
.getStatus()
6969
.addConditionsItem(
7070
new V1CertificateSigningRequestCondition()
71-
.type(V1CertificateSigningRequestCondition.TypeEnum.APPROVED)
71+
.type("Approved")
7272
.status("True")
7373
.reason("Kubernetes Java Client")
7474
.lastTransitionTime(now)

util/src/main/java/io/kubernetes/client/util/Yaml.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import io.kubernetes.client.common.KubernetesType;
1717
import io.kubernetes.client.custom.IntOrString;
1818
import io.kubernetes.client.custom.Quantity;
19-
import io.kubernetes.client.openapi.models.V1Container;
2019
import io.kubernetes.client.openapi.models.V1JSONSchemaProps;
2120
import java.io.File;
2221
import java.io.FileReader;
@@ -275,15 +274,6 @@ public CustomRepresenter() {
275274
this.representers.put(byte[].class, new RepresentByteArray());
276275
this.representers.put(Quantity.class, new RepresentQuantity());
277276
this.representers.put(OffsetDateTime.class, new RepresentDateTime());
278-
this.representers.put(V1Container.ImagePullPolicyEnum.class, new RepresentImagePull());
279-
}
280-
281-
private class RepresentImagePull implements Represent {
282-
@Override
283-
public Node representData(Object data) {
284-
return CustomRepresenter.this.representData(
285-
((V1Container.ImagePullPolicyEnum) data).getValue());
286-
}
287277
}
288278

289279
private class RepresentDateTime implements Represent {

util/src/main/java/io/kubernetes/client/util/taints/Taints.java

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,26 @@
1818
import java.util.Iterator;
1919

2020
public class Taints {
21-
public static V1Taint findTaint(V1Node node, String key, V1Taint.EffectEnum effect) {
21+
22+
public enum Effect {
23+
NO_SCHEDULE {
24+
public String toString() {
25+
return "NoSchedule";
26+
}
27+
},
28+
PREFER_NO_SCHEDULE {
29+
public String toString() {
30+
return "PreferNoSchedule";
31+
}
32+
},
33+
NO_EXECUTE {
34+
public String toString() {
35+
return "NoExcute";
36+
}
37+
}
38+
}
39+
40+
public static V1Taint findTaint(V1Node node, String key, Effect effect) {
2241
for (V1Taint taint : node.getSpec().getTaints()) {
2342
if (taint.getKey().equals(key) && taint.getEffect().equals(effect)) {
2443
return taint;
@@ -44,7 +63,7 @@ public static class TaintsBuilder {
4463
* @param key The key for the taint
4564
* @param effect The effect
4665
*/
47-
public TaintsBuilder addTaint(String key, V1Taint.EffectEnum effect) {
66+
public TaintsBuilder addTaint(String key, Effect effect) {
4867
return addTaint(key, null, effect);
4968
}
5069

@@ -54,11 +73,11 @@ public TaintsBuilder addTaint(String key, V1Taint.EffectEnum effect) {
5473
* @param key The key for the taint
5574
* @param effect The effect
5675
*/
57-
public TaintsBuilder addTaint(String key, String value, V1Taint.EffectEnum effect) {
76+
public TaintsBuilder addTaint(String key, String value, Effect effect) {
5877
V1Taint taint = new V1Taint();
5978
taint.setKey(key);
6079
taint.setValue(value);
61-
taint.setEffect(effect);
80+
taint.setEffect(effect.toString());
6281
if (node.getSpec() == null) {
6382
node.setSpec(new V1NodeSpec());
6483
}
@@ -72,7 +91,7 @@ public TaintsBuilder addTaint(String key, String value, V1Taint.EffectEnum effec
7291
* @param key The key for the taint
7392
* @param effect The effect
7493
*/
75-
public TaintsBuilder updateTaint(String key, String value, V1Taint.EffectEnum effect) {
94+
public TaintsBuilder updateTaint(String key, String value, Effect effect) {
7695
V1Taint taint = findTaint(node, key, effect);
7796
taint.setValue(value);
7897
return this;
@@ -81,7 +100,7 @@ public TaintsBuilder updateTaint(String key, String value, V1Taint.EffectEnum ef
81100
/**
82101
* Remove all taints matching a specified key
83102
*
84-
* @param The key for the taint(s) to remove
103+
* @param key: The key for the taint(s) to remove
85104
*/
86105
public TaintsBuilder removeTaint(String key) {
87106
if (node.getSpec() == null) {
@@ -103,7 +122,7 @@ public TaintsBuilder removeTaint(String key) {
103122
* @param key They key to match
104123
* @param effect The effect to match
105124
*/
106-
public TaintsBuilder removeTaint(String key, V1Taint.EffectEnum effect) {
125+
public TaintsBuilder removeTaint(String key, Effect effect) {
107126
if (node.getSpec() == null) {
108127
return this;
109128
}

util/src/test/java/io/kubernetes/client/util/taints/TaintsTest.java

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
*/
1313
package io.kubernetes.client.util.taints;
1414

15-
import static io.kubernetes.client.openapi.models.V1Taint.EffectEnum.NOEXECUTE;
16-
import static io.kubernetes.client.openapi.models.V1Taint.EffectEnum.NOSCHEDULE;
17-
import static io.kubernetes.client.openapi.models.V1Taint.EffectEnum.PREFERNOSCHEDULE;
1815
import static io.kubernetes.client.util.taints.Taints.taints;
1916
import static org.junit.Assert.assertNotNull;
2017
import static org.junit.Assert.assertNull;
@@ -26,36 +23,38 @@ public class TaintsTest {
2623
@Test
2724
public void testAddTaints() {
2825
V1Node node = new V1Node();
29-
taints(node).addTaint("key1", NOSCHEDULE).addTaint("key2", PREFERNOSCHEDULE);
26+
taints(node)
27+
.addTaint("key1", Taints.Effect.NO_SCHEDULE)
28+
.addTaint("key2", Taints.Effect.PREFER_NO_SCHEDULE);
3029

31-
assertNotNull(Taints.findTaint(node, "key1", NOSCHEDULE));
32-
assertNotNull(Taints.findTaint(node, "key2", PREFERNOSCHEDULE));
30+
assertNotNull(Taints.findTaint(node, "key1", Taints.Effect.NO_SCHEDULE));
31+
assertNotNull(Taints.findTaint(node, "key2", Taints.Effect.PREFER_NO_SCHEDULE));
3332
}
3433

3534
@Test
3635
public void testRemoveTaints() {
3736
V1Node node = new V1Node();
3837
taints(node)
39-
.addTaint("key1", NOSCHEDULE)
40-
.addTaint("key1", PREFERNOSCHEDULE)
41-
.addTaint("key1", NOEXECUTE)
42-
.addTaint("key2", PREFERNOSCHEDULE)
43-
.addTaint("key3", NOSCHEDULE)
44-
.addTaint("key3", NOEXECUTE);
38+
.addTaint("key1", Taints.Effect.NO_SCHEDULE)
39+
.addTaint("key1", Taints.Effect.PREFER_NO_SCHEDULE)
40+
.addTaint("key1", Taints.Effect.NO_EXECUTE)
41+
.addTaint("key2", Taints.Effect.PREFER_NO_SCHEDULE)
42+
.addTaint("key3", Taints.Effect.NO_SCHEDULE)
43+
.addTaint("key3", Taints.Effect.NO_EXECUTE);
4544

4645
taints(node)
4746
// Remove all
4847
.removeTaint("key1")
4948
// Shouldn't remove, 'effect' is different.
50-
.removeTaint("key2", NOSCHEDULE)
49+
.removeTaint("key2", Taints.Effect.NO_SCHEDULE)
5150
// Remove matching
52-
.removeTaint("key3", NOEXECUTE);
51+
.removeTaint("key3", Taints.Effect.NO_EXECUTE);
5352

54-
assertNull(Taints.findTaint(node, "key1", NOSCHEDULE));
55-
assertNull(Taints.findTaint(node, "key1", PREFERNOSCHEDULE));
56-
assertNull(Taints.findTaint(node, "key1", NOEXECUTE));
57-
assertNull(Taints.findTaint(node, "key3", NOEXECUTE));
58-
assertNotNull(Taints.findTaint(node, "key2", PREFERNOSCHEDULE));
59-
assertNotNull(Taints.findTaint(node, "key3", NOSCHEDULE));
53+
assertNull(Taints.findTaint(node, "key1", Taints.Effect.NO_SCHEDULE));
54+
assertNull(Taints.findTaint(node, "key1", Taints.Effect.PREFER_NO_SCHEDULE));
55+
assertNull(Taints.findTaint(node, "key1", Taints.Effect.NO_EXECUTE));
56+
assertNull(Taints.findTaint(node, "key3", Taints.Effect.NO_EXECUTE));
57+
assertNotNull(Taints.findTaint(node, "key2", Taints.Effect.PREFER_NO_SCHEDULE));
58+
assertNotNull(Taints.findTaint(node, "key3", Taints.Effect.NO_SCHEDULE));
6059
}
6160
}

0 commit comments

Comments
 (0)