Skip to content

Commit 09a9410

Browse files
authored
Merge pull request #1193 from sarveshkaushal/k-clean
Clean up various files
2 parents c492abb + 9d72d47 commit 09a9410

File tree

10 files changed

+20
-26
lines changed

10 files changed

+20
-26
lines changed

util/src/main/java/io/kubernetes/client/informer/cache/DeltaFIFO.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -443,11 +443,7 @@ private Deque<MutablePair<DeltaType, KubernetesObject>> combineDeltas(
443443
*/
444444
private MutablePair<DeltaType, KubernetesObject> isDuplicate(
445445
MutablePair<DeltaType, KubernetesObject> d1, MutablePair<DeltaType, KubernetesObject> d2) {
446-
MutablePair<DeltaType, KubernetesObject> deletionDelta = isDeletionDup(d1, d2);
447-
if (deletionDelta != null) {
448-
return deletionDelta;
449-
}
450-
return null;
446+
return isDeletionDup(d1, d2);
451447
}
452448

453449
/**

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ public class ModelMapper {
6262
public static void addModelMap(String apiGroupVersion, String kind, Class<?> clazz) {
6363
String[] parts = apiGroupVersion.split("/");
6464
if (parts.length == 1) {
65-
String version = apiGroupVersion;
66-
addModelMap("", version, kind, clazz);
65+
addModelMap("", apiGroupVersion, kind, clazz);
6766
}
6867
addModelMap(parts[0], parts[1], kind, clazz);
6968
}

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,7 @@ protected boolean isStatus(String line) throws IOException {
162162
break;
163163
}
164164
}
165-
if ("Status".equals(kind) && "v1".equals(apiVersion)) {
166-
return true;
167-
}
168-
return false;
165+
return "Status".equals(kind) && "v1".equals(apiVersion);
169166
}
170167

171168
protected Response<T> parseLine(String line) throws IOException {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private static enum State {
5353
UNINITIALIZED,
5454
OPEN,
5555
CLOSED
56-
};
56+
}
5757

5858
public synchronized void waitForInitialized() throws InterruptedException {
5959
if (state != State.UNINITIALIZED) {

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

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

15+
import io.kubernetes.client.common.KubernetesType;
1516
import io.kubernetes.client.custom.IntOrString;
1617
import io.kubernetes.client.custom.Quantity;
1718
import java.io.File;
@@ -201,7 +202,7 @@ public static void dump(Object object, Writer writer) {
201202
* @param data The list of YAML API objects
202203
* @return A String representing the list of YAML API objects.
203204
*/
204-
public static String dumpAll(Iterator<? extends Object> data) {
205+
public static String dumpAll(Iterator<? extends KubernetesType> data) {
205206
return getSnakeYaml().dumpAll(data);
206207
}
207208

@@ -211,7 +212,7 @@ public static String dumpAll(Iterator<? extends Object> data) {
211212
* @param data The list of YAML API objects.
212213
* @param output The writer to output the YAML String to.
213214
*/
214-
public static void dumpAll(Iterator<? extends Object> data, Writer output) {
215+
public static void dumpAll(Iterator<? extends KubernetesType> data, Writer output) {
215216
getSnakeYaml().dumpAll(data, output);
216217
}
217218

util/src/main/java/io/kubernetes/client/util/authenticators/OpenIDConnectAuthenticator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,8 @@ private String loadTokenURL(String issuer, SSLContext sslContext) {
282282
String json = scanner.useDelimiter("\\A").next();
283283

284284
JSONObject wellKnownJson = (JSONObject) new JSONParser().parse(json);
285-
String tokenUrl = (String) wellKnownJson.get("token_endpoint");
286285

287-
return tokenUrl;
286+
return (String) wellKnownJson.get("token_endpoint");
288287

289288
} catch (IOException | ParseException e) {
290289
throw new RuntimeException("Could not refresh", e);

util/src/main/java/io/kubernetes/client/util/generic/GenericKubernetesApi.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,9 @@ public KubernetesApiResponse<ApiType> get(String name, final GetOptions getOptio
295295
return executeCall(
296296
customObjectsApi.getApiClient(),
297297
apiTypeClass,
298-
() -> {
299-
Call call =
300-
customObjectsApi.getClusterCustomObjectCall(
301-
this.apiGroup, this.apiVersion, this.resourcePlural, name, null);
302-
303-
return call;
304-
});
298+
() ->
299+
customObjectsApi.getClusterCustomObjectCall(
300+
this.apiGroup, this.apiVersion, this.resourcePlural, name, null));
305301
}
306302

307303
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public String toString() {
3434
return "NoExcute";
3535
}
3636
}
37-
};
37+
}
3838

3939
public static V1Taint findTaint(V1Node node, String key, Effect effect) {
4040
for (V1Taint taint : node.getSpec().getTaints()) {

util/src/test/java/io/kubernetes/client/util/TestUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public enum DateOptions {
2727
Now,
2828
Future,
2929
Past
30-
};
30+
}
3131

3232
public static ApiKeyAuth getApiKeyAuthFromClient(ApiClient client) {
3333
return (ApiKeyAuth) client.getAuthentications().get("BearerToken");

util/src/test/java/io/kubernetes/client/util/YamlTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import static org.junit.Assert.assertTrue;
2222

2323
import com.google.common.io.Resources;
24+
import io.kubernetes.client.common.KubernetesType;
2425
import io.kubernetes.client.openapi.models.V1Deployment;
2526
import io.kubernetes.client.openapi.models.V1ObjectMeta;
2627
import io.kubernetes.client.openapi.models.V1Pod;
@@ -33,6 +34,7 @@
3334
import java.io.StringWriter;
3435
import java.lang.reflect.Method;
3536
import java.net.URL;
37+
import java.util.ArrayList;
3638
import java.util.List;
3739
import org.junit.Test;
3840

@@ -125,29 +127,33 @@ public void testLoadAll() throws IOException {
125127
@Test
126128
public void testLoadAllFile() throws Exception {
127129
List<Object> list = Yaml.loadAll(new File(TEST_YAML_FILE_PATH));
130+
List<KubernetesType> k8ObjectList = new ArrayList<>();
128131
for (Object object : list) {
129132
String type = object.getClass().getSimpleName();
130133
if (type.equals("V1Service")) {
131134
V1Service svc = (V1Service) object;
132135
assertEquals("v1", svc.getApiVersion());
133136
assertEquals("Service", svc.getKind());
134137
assertEquals("mock", svc.getMetadata().getName());
138+
k8ObjectList.add(svc);
135139
} else if (type.equals("V1Deployment")) {
136140
V1Deployment deploy = (V1Deployment) object;
137141
assertEquals("apps/v1", deploy.getApiVersion());
138142
assertEquals("Deployment", deploy.getKind());
139143
assertEquals("helloworld", deploy.getMetadata().getName());
144+
k8ObjectList.add(deploy);
140145
} else if (type.equals("V1Secret")) {
141146
V1Secret secret = (V1Secret) object;
142147
assertEquals("Secret", secret.getKind());
143148
assertEquals("secret", secret.getMetadata().getName());
144149
assertEquals("Opaque", secret.getType());
145150
assertEquals("hello", new String(secret.getData().get("secret-data"), UTF_8));
151+
k8ObjectList.add(secret);
146152
} else {
147153
throw new Exception("some thing wrong happened");
148154
}
149155
}
150-
String result = Yaml.dumpAll(list.iterator());
156+
String result = Yaml.dumpAll(k8ObjectList.iterator());
151157
String expected = Resources.toString(EXPECTED_YAML_FILE, UTF_8);
152158
assertThat(result, equalTo(expected));
153159
}

0 commit comments

Comments
 (0)