Skip to content

Commit

Permalink
reformat code (./mvnw fmt)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiokung committed Oct 24, 2019
1 parent 1601caa commit 7d90c23
Show file tree
Hide file tree
Showing 19 changed files with 79 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public static void main(String[] args) throws IOException, ApiException {
Configuration.setDefaultApiClient(client);

CoreV1Api api = new CoreV1Api();
V1PodList list = api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null);
V1PodList list =
api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null);
for (V1Pod item : list.getItems()) {
System.out.println(item.getMetadata().getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public static void main(String[] args) {

// List all of the namaspaces and pods
List<String> nameSpaces = getAllNameSpaces();
nameSpaces.stream()
nameSpaces
.stream()
.forEach(
namespace -> {
try {
Expand Down Expand Up @@ -104,7 +105,9 @@ public static List<String> getAllNameSpaces() throws ApiException {
COREV1_API.listNamespace(
"true", null, null, null, null, 0, null, Integer.MAX_VALUE, Boolean.FALSE);
List<String> list =
listNamespace.getItems().stream()
listNamespace
.getItems()
.stream()
.map(v1Namespace -> v1Namespace.getMetadata().getName())
.collect(Collectors.toList());
return list;
Expand All @@ -120,7 +123,9 @@ public static List<String> getPods() throws ApiException {
V1PodList v1podList =
COREV1_API.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null);
List<String> podList =
v1podList.getItems().stream()
v1podList
.getItems()
.stream()
.map(v1Pod -> v1Pod.getMetadata().getName())
.collect(Collectors.toList());
return podList;
Expand Down Expand Up @@ -169,7 +174,9 @@ public static List<String> getNamespacedPod(String namespace, String label) thro
TIME_OUT_VALUE,
Boolean.FALSE);
List<String> listPods =
listNamespacedPod.getItems().stream()
listNamespacedPod
.getItems()
.stream()
.map(v1pod -> v1pod.getMetadata().getName())
.collect(Collectors.toList());
return listPods;
Expand All @@ -194,7 +201,9 @@ public static List<String> getServices() throws ApiException {
null,
TIME_OUT_VALUE,
Boolean.FALSE);
return listNamespacedService.getItems().stream()
return listNamespacedService
.getItems()
.stream()
.map(v1service -> v1service.getMetadata().getName())
.collect(Collectors.toList());
}
Expand All @@ -217,7 +226,8 @@ public static void scaleDeployment(String deploymentName, int numberOfReplicas)
List<ExtensionsV1beta1Deployment> extensionsV1beta1DeploymentItems =
listNamespacedDeployment.getItems();
Optional<ExtensionsV1beta1Deployment> findedDeployment =
extensionsV1beta1DeploymentItems.stream()
extensionsV1beta1DeploymentItems
.stream()
.filter(
(ExtensionsV1beta1Deployment deployment) ->
deployment.getMetadata().getName().equals(deploymentName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public static void main(String[] args) throws IOException, ApiException {
CoreV1Api api = new CoreV1Api();

// invokes the CoreV1Api client
V1PodList list = api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null);
V1PodList list =
api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null);
for (V1Pod item : list.getItems()) {
System.out.println(item.getMetadata().getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
import io.kubernetes.client.models.V1ObjectMeta;
import io.kubernetes.client.util.CallGeneratorParams;
import io.kubernetes.client.util.Config;
import okhttp3.OkHttpClient;

import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient;

/**
* A simple example of how to use the Java API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public static void main(String[] args) throws IOException, ApiException {
CoreV1Api api = new CoreV1Api();

// invokes the CoreV1Api client
V1PodList list = api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null);
V1PodList list =
api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null);
for (V1Pod item : list.getItems()) {
System.out.println(item.getMetadata().getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
import io.kubernetes.client.models.V1Namespace;
import io.kubernetes.client.models.V1NamespaceList;
import io.kubernetes.client.util.Config;
import okhttp3.OkHttpClient;

import java.io.IOException;
import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient;

/**
* A simple example of how to use the Java API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
import io.kubernetes.client.models.V1Namespace;
import io.kubernetes.client.util.Config;
import io.kubernetes.client.util.Watch;
import okhttp3.OkHttpClient;

import java.io.IOException;
import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient;

/** A simple example of how to use Watch API to watch changes in Namespace list. */
public class WatchExample {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
import io.kubernetes.client.ApiException;
import io.kubernetes.client.util.Config;
import io.kubernetes.client.util.WebSockets;
import okhttp3.WebSocket;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import okhttp3.WebSocket;

/**
* This is a pretty low level, most people won't need to use WebSockets directly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
import io.kubernetes.client.ApiException;
import io.kubernetes.client.util.Reflect;
import io.kubernetes.client.util.exception.ObjectMetaReflectException;
import okhttp3.Call;

import java.io.IOException;
import java.lang.reflect.Type;
import java.util.Iterator;
import java.util.function.Function;
import okhttp3.Call;

/*
* Pager encapsulates kubernetes limit/continue-based list pagination into an iterator.
Expand Down
5 changes: 2 additions & 3 deletions util/src/main/java/io/kubernetes/client/PodLogs.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
*/
package io.kubernetes.client;

import java.io.IOException;
import java.io.InputStream;

import io.kubernetes.client.apis.CoreV1Api;
import io.kubernetes.client.models.V1Pod;
import java.io.IOException;
import java.io.InputStream;
import okhttp3.Call;
import okhttp3.Response;

Expand Down
11 changes: 5 additions & 6 deletions util/src/main/java/io/kubernetes/client/ProtoClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@

package io.kubernetes.client;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;

import com.google.common.io.ByteStreams;
import com.google.common.primitives.Bytes;
import com.google.protobuf.Message;
import io.kubernetes.client.proto.Meta.DeleteOptions;
import io.kubernetes.client.proto.Meta.Status;
import io.kubernetes.client.proto.Runtime.TypeMeta;
import io.kubernetes.client.proto.Runtime.Unknown;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.RequestBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.apache.commons.collections4.MapUtils;
import okhttp3.Call;
import okhttp3.OkHttpClient;
import org.apache.commons.collections4.MapUtils;

/** SharedInformerFactory class constructs and caches informers for api types. */
public class SharedInformerFactory {
Expand Down
51 changes: 27 additions & 24 deletions util/src/main/java/io/kubernetes/client/util/ClientBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;

import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.slf4j.Logger;
Expand Down Expand Up @@ -321,29 +321,32 @@ public ApiClient build() {
}

if (!Strings.isNullOrEmpty(overridePatchFormat)) {
client
.getHttpClient()
.interceptors()
.add(
new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();

if ("PATCH".equals(request.method())) {

Request newRequest =
request
.newBuilder()
.patch(
new ProxyContentTypeRequestBody(
request.body(), overridePatchFormat))
.build();
return chain.proceed(newRequest);
}
return chain.proceed(request);
}
});
OkHttpClient withInterceptor =
client
.getHttpClient()
.newBuilder()
.addInterceptor(
new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();

if ("PATCH".equals(request.method())) {

Request newRequest =
request
.newBuilder()
.patch(
new ProxyContentTypeRequestBody(
request.body(), overridePatchFormat))
.build();
return chain.proceed(newRequest);
}
return chain.proceed(request);
}
})
.build();
client.setHttpClient(withInterceptor);
}
return client;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package io.kubernetes.client.util;

import java.io.IOException;

import com.google.common.base.Strings;
import java.io.IOException;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okio.BufferedSink;
Expand Down
11 changes: 5 additions & 6 deletions util/src/main/java/io/kubernetes/client/util/Watch.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@
*/
package io.kubernetes.client.util;

import java.io.Closeable;
import java.io.IOException;
import java.io.StringReader;
import java.lang.reflect.Type;
import java.util.Iterator;

import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import io.kubernetes.client.ApiClient;
import io.kubernetes.client.ApiException;
import io.kubernetes.client.JSON;
import io.kubernetes.client.models.V1Status;
import java.io.Closeable;
import java.io.IOException;
import java.io.StringReader;
import java.lang.reflect.Type;
import java.util.Iterator;
import okhttp3.Call;
import okhttp3.ResponseBody;
import org.slf4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
*/
package io.kubernetes.client.util;

import com.google.common.base.Charsets;
import com.google.common.io.ByteStreams;
import com.google.common.io.CharStreams;
import java.io.ByteArrayInputStream;
import java.io.Closeable;
import java.io.IOException;
Expand All @@ -23,10 +26,6 @@
import java.io.Reader;
import java.util.HashMap;
import java.util.Map;

import com.google.common.base.Charsets;
import com.google.common.io.ByteStreams;
import com.google.common.io.CharStreams;
import okhttp3.WebSocket;
import okio.ByteString;
import org.slf4j.Logger;
Expand Down
9 changes: 4 additions & 5 deletions util/src/main/java/io/kubernetes/client/util/WebSockets.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
*/
package io.kubernetes.client.util;

import com.google.common.net.HttpHeaders;
import io.kubernetes.client.ApiClient;
import io.kubernetes.client.ApiException;
import io.kubernetes.client.Pair;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
Expand All @@ -21,11 +25,6 @@
import java.util.HashMap;
import java.util.List;
import javax.annotation.Nullable;

import com.google.common.net.HttpHeaders;
import io.kubernetes.client.ApiClient;
import io.kubernetes.client.ApiException;
import io.kubernetes.client.Pair;
import okhttp3.Call;
import okhttp3.Request;
import okhttp3.Response;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
package io.kubernetes.client;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import io.kubernetes.client.util.WebSocketStreamHandler;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;

import io.kubernetes.client.util.WebSocketStreamHandler;
import okhttp3.Request;
import okhttp3.WebSocket;
import okio.BufferedSink;
import okio.ByteString;
import okio.Okio;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class WebsocketStreamHandlerTest {

private static String testProtocol = "test-protocol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import io.kubernetes.client.custom.V1Patch;
import java.io.IOException;
import java.util.HashMap;

import okhttp3.Call;
import org.junit.Before;
import org.junit.Rule;
Expand Down

0 comments on commit 7d90c23

Please sign in to comment.