Skip to content

Commit 997c088

Browse files
Merge pull request #183 from lewisheadden/UseGoogleJavaFormat
Use Google Java Format
2 parents 959464b + 080c384 commit 997c088

37 files changed

+2311
-2235
lines changed

examples/pom.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,19 @@
7272
</execution>
7373
</executions>
7474
</plugin>
75+
<plugin>
76+
<groupId>com.coveo</groupId>
77+
<artifactId>fmt-maven-plugin</artifactId>
78+
<version>2.2.0</version>
79+
<executions>
80+
<execution>
81+
<phase>test</phase>
82+
<goals>
83+
<goal>check</goal>
84+
</goals>
85+
</execution>
86+
</executions>
87+
</plugin>
7588
</plugins>
7689
</build>
7790
<properties>

examples/src/main/java/io/kubernetes/client/examples/AttachExample.java

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,67 +12,66 @@
1212
*/
1313
package io.kubernetes.client.examples;
1414

15+
import com.google.common.io.ByteStreams;
1516
import io.kubernetes.client.ApiClient;
1617
import io.kubernetes.client.ApiException;
17-
import io.kubernetes.client.Configuration;
1818
import io.kubernetes.client.Attach;
19-
import io.kubernetes.client.apis.CoreV1Api;
20-
import io.kubernetes.client.models.V1Pod;
21-
import io.kubernetes.client.models.V1PodList;
19+
import io.kubernetes.client.Configuration;
2220
import io.kubernetes.client.util.Config;
23-
24-
import com.google.common.io.ByteStreams;
25-
2621
import java.io.BufferedReader;
27-
import java.io.InputStreamReader;
2822
import java.io.IOException;
23+
import java.io.InputStreamReader;
2924
import java.io.OutputStream;
3025

3126
/**
3227
* A simple example of how to use the Java API
33-
*
34-
* <p>Easiest way to run this:
35-
* mvn exec:java -Dexec.mainClass="io.kubernetes.client.examples.AttachExample"
36-
*
28+
*
29+
* <p>Easiest way to run this: mvn exec:java
30+
* -Dexec.mainClass="io.kubernetes.client.examples.AttachExample"
31+
*
3732
* <p>From inside $REPO_DIR/examples
3833
*/
3934
public class AttachExample {
40-
public static void main(String[] args) throws IOException, ApiException, InterruptedException {
41-
ApiClient client = Config.defaultClient();
42-
Configuration.setDefaultApiClient(client);
35+
public static void main(String[] args) throws IOException, ApiException, InterruptedException {
36+
ApiClient client = Config.defaultClient();
37+
Configuration.setDefaultApiClient(client);
4338

44-
Attach attach = new Attach();
45-
final Attach.AttachResult result = attach.attach("default", "nginx-4217019353-k5sn9", true);
39+
Attach attach = new Attach();
40+
final Attach.AttachResult result = attach.attach("default", "nginx-4217019353-k5sn9", true);
4641

47-
new Thread(new Runnable() {
48-
public void run() {
42+
new Thread(
43+
new Runnable() {
44+
public void run() {
4945
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
5046
OutputStream output = result.getStandardInputStream();
5147
try {
52-
while (true) {
53-
String line = in.readLine();
54-
output.write(line.getBytes());
55-
output.write('\n');
56-
output.flush();
57-
}
48+
while (true) {
49+
String line = in.readLine();
50+
output.write(line.getBytes());
51+
output.write('\n');
52+
output.flush();
53+
}
5854
} catch (IOException ex) {
59-
ex.printStackTrace();
55+
ex.printStackTrace();
6056
}
61-
}
62-
}).start();
57+
}
58+
})
59+
.start();
6360

64-
new Thread(new Runnable() {
65-
public void run() {
61+
new Thread(
62+
new Runnable() {
63+
public void run() {
6664
try {
67-
ByteStreams.copy(result.getStandardOutputStream(), System.out);
65+
ByteStreams.copy(result.getStandardOutputStream(), System.out);
6866
} catch (IOException ex) {
69-
ex.printStackTrace();
67+
ex.printStackTrace();
7068
}
71-
}
72-
}).start();
69+
}
70+
})
71+
.start();
7372

74-
Thread.sleep(10*1000);
75-
result.close();
76-
System.exit(0);
77-
}
73+
Thread.sleep(10 * 1000);
74+
result.close();
75+
System.exit(0);
76+
}
7877
}

examples/src/main/java/io/kubernetes/client/examples/Example.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,26 @@
1919
import io.kubernetes.client.models.V1Pod;
2020
import io.kubernetes.client.models.V1PodList;
2121
import io.kubernetes.client.util.Config;
22-
2322
import java.io.IOException;
24-
import java.util.logging.Logger;
2523

2624
/**
2725
* A simple example of how to use the Java API
28-
*
29-
* <p>Easiest way to run this:
30-
* mvn exec:java -Dexec.mainClass="io.kubernetes.client.examples.Example"
31-
*
26+
*
27+
* <p>Easiest way to run this: mvn exec:java
28+
* -Dexec.mainClass="io.kubernetes.client.examples.Example"
29+
*
3230
* <p>From inside $REPO_DIR/examples
3331
*/
3432
public class Example {
35-
public static void main(String[] args) throws IOException, ApiException{
36-
ApiClient client = Config.defaultClient();
37-
Configuration.setDefaultApiClient(client);
33+
public static void main(String[] args) throws IOException, ApiException {
34+
ApiClient client = Config.defaultClient();
35+
Configuration.setDefaultApiClient(client);
3836

39-
CoreV1Api api = new CoreV1Api();
40-
V1PodList list = api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null);
41-
for (V1Pod item : list.getItems()) {
42-
System.out.println(item.getMetadata().getName());
43-
}
37+
CoreV1Api api = new CoreV1Api();
38+
V1PodList list =
39+
api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null);
40+
for (V1Pod item : list.getItems()) {
41+
System.out.println(item.getMetadata().getName());
4442
}
45-
}
43+
}
44+
}

examples/src/main/java/io/kubernetes/client/examples/ExecExample.java

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,71 +12,68 @@
1212
*/
1313
package io.kubernetes.client.examples;
1414

15+
import com.google.common.io.ByteStreams;
1516
import io.kubernetes.client.ApiClient;
1617
import io.kubernetes.client.ApiException;
1718
import io.kubernetes.client.Configuration;
1819
import io.kubernetes.client.Exec;
19-
import io.kubernetes.client.apis.CoreV1Api;
20-
import io.kubernetes.client.models.V1Pod;
21-
import io.kubernetes.client.models.V1PodList;
2220
import io.kubernetes.client.util.Config;
23-
24-
import com.google.common.io.ByteStreams;
25-
26-
import java.io.BufferedReader;
27-
import java.io.InputStreamReader;
2821
import java.io.IOException;
29-
import java.io.OutputStream;
3022

3123
/**
3224
* A simple example of how to use the Java API
33-
*
34-
* <p>Easiest way to run this:
35-
* mvn exec:java -Dexec.mainClass="io.kubernetes.client.examples.Example"
36-
*
25+
*
26+
* <p>Easiest way to run this: mvn exec:java
27+
* -Dexec.mainClass="io.kubernetes.client.examples.Example"
28+
*
3729
* <p>From inside $REPO_DIR/examples
3830
*/
3931
public class ExecExample {
40-
public static void main(String[] args) throws IOException, ApiException, InterruptedException {
41-
ApiClient client = Config.defaultClient();
42-
Configuration.setDefaultApiClient(client);
32+
public static void main(String[] args) throws IOException, ApiException, InterruptedException {
33+
ApiClient client = Config.defaultClient();
34+
Configuration.setDefaultApiClient(client);
4335

44-
Exec exec = new Exec();
45-
boolean tty = System.console() != null;
46-
// final Process proc = exec.exec("default", "nginx-2371676037-czqx3", new String[] {"sh", "-c", "echo foo"}, true, tty);
47-
final Process proc = exec.exec("default", "nginx-4217019353-k5sn9", new String[] {"sh"}, true, tty);
36+
Exec exec = new Exec();
37+
boolean tty = System.console() != null;
38+
// final Process proc = exec.exec("default", "nginx-2371676037-czqx3", new String[]
39+
// {"sh", "-c", "echo foo"}, true, tty);
40+
final Process proc =
41+
exec.exec("default", "nginx-4217019353-k5sn9", new String[] {"sh"}, true, tty);
4842

49-
50-
new Thread(new Runnable() {
51-
public void run() {
43+
new Thread(
44+
new Runnable() {
45+
public void run() {
5246
try {
53-
ByteStreams.copy(System.in, proc.getOutputStream());
47+
ByteStreams.copy(System.in, proc.getOutputStream());
5448
} catch (IOException ex) {
55-
ex.printStackTrace();
49+
ex.printStackTrace();
5650
}
57-
}
58-
}).start();
51+
}
52+
})
53+
.start();
5954

60-
new Thread(new Runnable() {
61-
public void run() {
55+
new Thread(
56+
new Runnable() {
57+
public void run() {
6258
try {
63-
ByteStreams.copy(proc.getInputStream(), System.out);
59+
ByteStreams.copy(proc.getInputStream(), System.out);
6460
} catch (IOException ex) {
65-
ex.printStackTrace();
61+
ex.printStackTrace();
6662
}
67-
}
68-
}).start();
63+
}
64+
})
65+
.start();
6966

70-
proc.waitFor();
71-
try {
72-
// Wait for buffers to flush.
73-
Thread.sleep(2000);
74-
} catch (InterruptedException ex) {
75-
ex.printStackTrace();
76-
}
67+
proc.waitFor();
68+
try {
69+
// Wait for buffers to flush.
70+
Thread.sleep(2000);
71+
} catch (InterruptedException ex) {
72+
ex.printStackTrace();
73+
}
7774

78-
proc.destroy();
75+
proc.destroy();
7976

80-
System.exit(0);
81-
}
82-
}
77+
System.exit(0);
78+
}
79+
}

examples/src/main/java/io/kubernetes/client/examples/LogsExample.java

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,39 @@
1212
*/
1313
package io.kubernetes.client.examples;
1414

15+
import com.google.common.io.ByteStreams;
1516
import io.kubernetes.client.ApiClient;
1617
import io.kubernetes.client.ApiException;
1718
import io.kubernetes.client.Configuration;
1819
import io.kubernetes.client.PodLogs;
1920
import io.kubernetes.client.apis.CoreV1Api;
2021
import io.kubernetes.client.models.V1Pod;
21-
import io.kubernetes.client.models.V1PodList;
2222
import io.kubernetes.client.util.Config;
23-
24-
import com.google.common.io.ByteStreams;
25-
26-
import java.io.BufferedReader;
27-
import java.io.InputStream;
28-
import java.io.InputStreamReader;
2923
import java.io.IOException;
30-
import java.io.OutputStream;
24+
import java.io.InputStream;
3125

3226
/**
3327
* A simple example of how to use the Java API
34-
*
35-
* <p>Easiest way to run this:
36-
* mvn exec:java -Dexec.mainClass="io.kubernetes.client.examples.LogsExample"
37-
*
28+
*
29+
* <p>Easiest way to run this: mvn exec:java
30+
* -Dexec.mainClass="io.kubernetes.client.examples.LogsExample"
31+
*
3832
* <p>From inside $REPO_DIR/examples
3933
*/
4034
public class LogsExample {
41-
public static void main(String[] args) throws IOException, ApiException, InterruptedException {
42-
ApiClient client = Config.defaultClient();
43-
Configuration.setDefaultApiClient(client);
44-
CoreV1Api coreApi = new CoreV1Api(client);
35+
public static void main(String[] args) throws IOException, ApiException, InterruptedException {
36+
ApiClient client = Config.defaultClient();
37+
Configuration.setDefaultApiClient(client);
38+
CoreV1Api coreApi = new CoreV1Api(client);
4539

46-
PodLogs logs = new PodLogs();
47-
V1Pod pod = coreApi.listNamespacedPod("default", "false", null, null, null, null, null, null, null, null).getItems().get(0);
40+
PodLogs logs = new PodLogs();
41+
V1Pod pod =
42+
coreApi
43+
.listNamespacedPod("default", "false", null, null, null, null, null, null, null, null)
44+
.getItems()
45+
.get(0);
4846

49-
InputStream is = logs.streamNamespacedPodLog(pod);
50-
ByteStreams.copy(is, System.out);
51-
}
47+
InputStream is = logs.streamNamespacedPodLog(pod);
48+
ByteStreams.copy(is, System.out);
49+
}
5250
}

0 commit comments

Comments
 (0)