Skip to content

Commit

Permalink
Merge pull request #183 from lewisheadden/UseGoogleJavaFormat
Browse files Browse the repository at this point in the history
Use Google Java Format
  • Loading branch information
brendandburns authored Feb 14, 2018
2 parents 959464b + 080c384 commit 997c088
Show file tree
Hide file tree
Showing 37 changed files with 2,311 additions and 2,235 deletions.
13 changes: 13 additions & 0 deletions examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.coveo</groupId>
<artifactId>fmt-maven-plugin</artifactId>
<version>2.2.0</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,67 +12,66 @@
*/
package io.kubernetes.client.examples;

import com.google.common.io.ByteStreams;
import io.kubernetes.client.ApiClient;
import io.kubernetes.client.ApiException;
import io.kubernetes.client.Configuration;
import io.kubernetes.client.Attach;
import io.kubernetes.client.apis.CoreV1Api;
import io.kubernetes.client.models.V1Pod;
import io.kubernetes.client.models.V1PodList;
import io.kubernetes.client.Configuration;
import io.kubernetes.client.util.Config;

import com.google.common.io.ByteStreams;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;

/**
* A simple example of how to use the Java API
*
* <p>Easiest way to run this:
* mvn exec:java -Dexec.mainClass="io.kubernetes.client.examples.AttachExample"
*
*
* <p>Easiest way to run this: mvn exec:java
* -Dexec.mainClass="io.kubernetes.client.examples.AttachExample"
*
* <p>From inside $REPO_DIR/examples
*/
public class AttachExample {
public static void main(String[] args) throws IOException, ApiException, InterruptedException {
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);
public static void main(String[] args) throws IOException, ApiException, InterruptedException {
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);

Attach attach = new Attach();
final Attach.AttachResult result = attach.attach("default", "nginx-4217019353-k5sn9", true);
Attach attach = new Attach();
final Attach.AttachResult result = attach.attach("default", "nginx-4217019353-k5sn9", true);

new Thread(new Runnable() {
public void run() {
new Thread(
new Runnable() {
public void run() {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
OutputStream output = result.getStandardInputStream();
try {
while (true) {
String line = in.readLine();
output.write(line.getBytes());
output.write('\n');
output.flush();
}
while (true) {
String line = in.readLine();
output.write(line.getBytes());
output.write('\n');
output.flush();
}
} catch (IOException ex) {
ex.printStackTrace();
ex.printStackTrace();
}
}
}).start();
}
})
.start();

new Thread(new Runnable() {
public void run() {
new Thread(
new Runnable() {
public void run() {
try {
ByteStreams.copy(result.getStandardOutputStream(), System.out);
ByteStreams.copy(result.getStandardOutputStream(), System.out);
} catch (IOException ex) {
ex.printStackTrace();
ex.printStackTrace();
}
}
}).start();
}
})
.start();

Thread.sleep(10*1000);
result.close();
System.exit(0);
}
Thread.sleep(10 * 1000);
result.close();
System.exit(0);
}
}
29 changes: 14 additions & 15 deletions examples/src/main/java/io/kubernetes/client/examples/Example.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,26 @@
import io.kubernetes.client.models.V1Pod;
import io.kubernetes.client.models.V1PodList;
import io.kubernetes.client.util.Config;

import java.io.IOException;
import java.util.logging.Logger;

/**
* A simple example of how to use the Java API
*
* <p>Easiest way to run this:
* mvn exec:java -Dexec.mainClass="io.kubernetes.client.examples.Example"
*
*
* <p>Easiest way to run this: mvn exec:java
* -Dexec.mainClass="io.kubernetes.client.examples.Example"
*
* <p>From inside $REPO_DIR/examples
*/
public class Example {
public static void main(String[] args) throws IOException, ApiException{
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);
public static void main(String[] args) throws IOException, ApiException {
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);

CoreV1Api api = new CoreV1Api();
V1PodList list = api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null);
for (V1Pod item : list.getItems()) {
System.out.println(item.getMetadata().getName());
}
CoreV1Api api = new CoreV1Api();
V1PodList list =
api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null);
for (V1Pod item : list.getItems()) {
System.out.println(item.getMetadata().getName());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,71 +12,68 @@
*/
package io.kubernetes.client.examples;

import com.google.common.io.ByteStreams;
import io.kubernetes.client.ApiClient;
import io.kubernetes.client.ApiException;
import io.kubernetes.client.Configuration;
import io.kubernetes.client.Exec;
import io.kubernetes.client.apis.CoreV1Api;
import io.kubernetes.client.models.V1Pod;
import io.kubernetes.client.models.V1PodList;
import io.kubernetes.client.util.Config;

import com.google.common.io.ByteStreams;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStream;

/**
* A simple example of how to use the Java API
*
* <p>Easiest way to run this:
* mvn exec:java -Dexec.mainClass="io.kubernetes.client.examples.Example"
*
*
* <p>Easiest way to run this: mvn exec:java
* -Dexec.mainClass="io.kubernetes.client.examples.Example"
*
* <p>From inside $REPO_DIR/examples
*/
public class ExecExample {
public static void main(String[] args) throws IOException, ApiException, InterruptedException {
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);
public static void main(String[] args) throws IOException, ApiException, InterruptedException {
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);

Exec exec = new Exec();
boolean tty = System.console() != null;
// final Process proc = exec.exec("default", "nginx-2371676037-czqx3", new String[] {"sh", "-c", "echo foo"}, true, tty);
final Process proc = exec.exec("default", "nginx-4217019353-k5sn9", new String[] {"sh"}, true, tty);
Exec exec = new Exec();
boolean tty = System.console() != null;
// final Process proc = exec.exec("default", "nginx-2371676037-czqx3", new String[]
// {"sh", "-c", "echo foo"}, true, tty);
final Process proc =
exec.exec("default", "nginx-4217019353-k5sn9", new String[] {"sh"}, true, tty);


new Thread(new Runnable() {
public void run() {
new Thread(
new Runnable() {
public void run() {
try {
ByteStreams.copy(System.in, proc.getOutputStream());
ByteStreams.copy(System.in, proc.getOutputStream());
} catch (IOException ex) {
ex.printStackTrace();
ex.printStackTrace();
}
}
}).start();
}
})
.start();

new Thread(new Runnable() {
public void run() {
new Thread(
new Runnable() {
public void run() {
try {
ByteStreams.copy(proc.getInputStream(), System.out);
ByteStreams.copy(proc.getInputStream(), System.out);
} catch (IOException ex) {
ex.printStackTrace();
ex.printStackTrace();
}
}
}).start();
}
})
.start();

proc.waitFor();
try {
// Wait for buffers to flush.
Thread.sleep(2000);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
proc.waitFor();
try {
// Wait for buffers to flush.
Thread.sleep(2000);
} catch (InterruptedException ex) {
ex.printStackTrace();
}

proc.destroy();
proc.destroy();

System.exit(0);
}
}
System.exit(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,39 @@
*/
package io.kubernetes.client.examples;

import com.google.common.io.ByteStreams;
import io.kubernetes.client.ApiClient;
import io.kubernetes.client.ApiException;
import io.kubernetes.client.Configuration;
import io.kubernetes.client.PodLogs;
import io.kubernetes.client.apis.CoreV1Api;
import io.kubernetes.client.models.V1Pod;
import io.kubernetes.client.models.V1PodList;
import io.kubernetes.client.util.Config;

import com.google.common.io.ByteStreams;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStream;
import java.io.InputStream;

/**
* A simple example of how to use the Java API
*
* <p>Easiest way to run this:
* mvn exec:java -Dexec.mainClass="io.kubernetes.client.examples.LogsExample"
*
*
* <p>Easiest way to run this: mvn exec:java
* -Dexec.mainClass="io.kubernetes.client.examples.LogsExample"
*
* <p>From inside $REPO_DIR/examples
*/
public class LogsExample {
public static void main(String[] args) throws IOException, ApiException, InterruptedException {
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);
CoreV1Api coreApi = new CoreV1Api(client);
public static void main(String[] args) throws IOException, ApiException, InterruptedException {
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);
CoreV1Api coreApi = new CoreV1Api(client);

PodLogs logs = new PodLogs();
V1Pod pod = coreApi.listNamespacedPod("default", "false", null, null, null, null, null, null, null, null).getItems().get(0);
PodLogs logs = new PodLogs();
V1Pod pod =
coreApi
.listNamespacedPod("default", "false", null, null, null, null, null, null, null, null)
.getItems()
.get(0);

InputStream is = logs.streamNamespacedPodLog(pod);
ByteStreams.copy(is, System.out);
}
InputStream is = logs.streamNamespacedPodLog(pod);
ByteStreams.copy(is, System.out);
}
}
Loading

0 comments on commit 997c088

Please sign in to comment.