Skip to content

Commit 385b070

Browse files
authored
Merge pull request #1444 from dsyer/examples-guava
Factor Guava out of examples
2 parents 49cf295 + 421dc32 commit 385b070

File tree

17 files changed

+158
-151
lines changed

17 files changed

+158
-151
lines changed

examples/examples-release-10/pom.xml

Lines changed: 104 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2-
<modelVersion>4.0.0</modelVersion>
2+
<modelVersion>4.0.0</modelVersion>
33

4-
<parent>
5-
<groupId>io.kubernetes</groupId>
6-
<artifactId>client-java-examples-parent</artifactId>
7-
<version>1.0.0-SNAPSHOT</version>
8-
<relativePath>../pom.xml</relativePath>
9-
</parent>
4+
<parent>
5+
<groupId>io.kubernetes</groupId>
6+
<artifactId>client-java-examples-parent</artifactId>
7+
<version>1.0.0-SNAPSHOT</version>
8+
<relativePath>../pom.xml</relativePath>
9+
</parent>
1010

11-
<artifactId>client-java-examples-release-10</artifactId>
12-
<packaging>bundle</packaging>
13-
<name>client-java-examples-release-10</name>
11+
<artifactId>client-java-examples-release-10</artifactId>
12+
<packaging>bundle</packaging>
13+
<name>client-java-examples-release-10</name>
1414

15-
<properties>
16-
<kubernetes.client.version>10.0.0</kubernetes.client.version>
17-
</properties>
18-
<dependencies>
15+
<properties>
16+
<kubernetes.client.version>10.0.0</kubernetes.client.version>
17+
</properties>
18+
<dependencies>
1919
<dependency>
2020
<groupId>io.prometheus</groupId>
2121
<artifactId>simpleclient</artifactId>
@@ -26,99 +26,95 @@
2626
<artifactId>simpleclient_httpserver</artifactId>
2727
<version>0.9.0</version>
2828
</dependency>
29-
<dependency>
30-
<groupId>io.kubernetes</groupId>
31-
<artifactId>client-java-api</artifactId>
32-
<version>${kubernetes.client.version}</version>
33-
</dependency>
34-
<dependency>
35-
<groupId>io.kubernetes</groupId>
36-
<artifactId>client-java</artifactId>
37-
<version>${kubernetes.client.version}</version>
38-
</dependency>
39-
<dependency>
40-
<groupId>io.kubernetes</groupId>
41-
<artifactId>client-java-extended</artifactId>
42-
<version>${kubernetes.client.version}</version>
43-
</dependency>
44-
<dependency>
45-
<groupId>io.kubernetes</groupId>
46-
<artifactId>client-java-spring-integration</artifactId>
47-
<version>${kubernetes.client.version}</version>
48-
</dependency>
49-
<dependency>
50-
<groupId>io.kubernetes</groupId>
51-
<artifactId>client-java-proto</artifactId>
52-
<version>${kubernetes.client.version}</version>
53-
</dependency>
54-
<dependency>
55-
<groupId>com.google.guava</groupId>
56-
<artifactId>guava</artifactId>
57-
</dependency>
58-
<dependency>
59-
<groupId>commons-cli</groupId>
60-
<artifactId>commons-cli</artifactId>
61-
</dependency>
62-
<dependency>
63-
<groupId>io.kubernetes</groupId>
64-
<artifactId>client-java-cert-manager-models</artifactId>
65-
<version>10.0.0</version>
66-
</dependency>
67-
<dependency>
68-
<groupId>io.kubernetes</groupId>
69-
<artifactId>client-java-prometheus-operator-models</artifactId>
70-
<version>10.0.0</version>
71-
</dependency>
72-
<!-- test dependencies -->
73-
<dependency>
74-
<groupId>junit</groupId>
75-
<artifactId>junit</artifactId>
76-
<scope>test</scope>
77-
</dependency>
78-
<dependency>
79-
<groupId>com.github.tomakehurst</groupId>
80-
<artifactId>wiremock</artifactId>
81-
<scope>test</scope>
82-
</dependency>
83-
</dependencies>
84-
<build>
85-
<plugins>
86-
<plugin>
87-
<groupId>org.apache.felix</groupId>
88-
<artifactId>maven-bundle-plugin</artifactId>
89-
<extensions>true</extensions>
90-
</plugin>
91-
<plugin>
92-
<groupId>org.apache.maven.plugins</groupId>
93-
<artifactId>maven-deploy-plugin</artifactId>
94-
<version>2.8.2</version>
95-
<configuration>
96-
<skip>true</skip>
97-
</configuration>
98-
</plugin>
99-
<plugin>
100-
<groupId>org.apache.maven.plugins</groupId>
101-
<artifactId>maven-assembly-plugin</artifactId>
102-
<executions>
103-
<execution>
104-
<phase>package</phase>
105-
<goals>
106-
<goal>single</goal>
107-
</goals>
108-
<configuration>
109-
<archive>
110-
<manifest>
111-
<mainClass>io.kubernetes.client.examples.Example</mainClass>
112-
</manifest>
113-
</archive>
114-
<descriptorRefs>
115-
<descriptorRef>jar-with-dependencies</descriptorRef>
116-
</descriptorRefs>
117-
</configuration>
118-
</execution>
119-
</executions>
120-
</plugin>
121-
</plugins>
122-
</build>
29+
<dependency>
30+
<groupId>io.kubernetes</groupId>
31+
<artifactId>client-java-api</artifactId>
32+
<version>${kubernetes.client.version}</version>
33+
</dependency>
34+
<dependency>
35+
<groupId>io.kubernetes</groupId>
36+
<artifactId>client-java</artifactId>
37+
<version>${kubernetes.client.version}</version>
38+
</dependency>
39+
<dependency>
40+
<groupId>io.kubernetes</groupId>
41+
<artifactId>client-java-extended</artifactId>
42+
<version>${kubernetes.client.version}</version>
43+
</dependency>
44+
<dependency>
45+
<groupId>io.kubernetes</groupId>
46+
<artifactId>client-java-spring-integration</artifactId>
47+
<version>${kubernetes.client.version}</version>
48+
</dependency>
49+
<dependency>
50+
<groupId>io.kubernetes</groupId>
51+
<artifactId>client-java-proto</artifactId>
52+
<version>${kubernetes.client.version}</version>
53+
</dependency>
54+
<dependency>
55+
<groupId>commons-cli</groupId>
56+
<artifactId>commons-cli</artifactId>
57+
</dependency>
58+
<dependency>
59+
<groupId>io.kubernetes</groupId>
60+
<artifactId>client-java-cert-manager-models</artifactId>
61+
<version>10.0.0</version>
62+
</dependency>
63+
<dependency>
64+
<groupId>io.kubernetes</groupId>
65+
<artifactId>client-java-prometheus-operator-models</artifactId>
66+
<version>10.0.0</version>
67+
</dependency>
68+
<!-- test dependencies -->
69+
<dependency>
70+
<groupId>junit</groupId>
71+
<artifactId>junit</artifactId>
72+
<scope>test</scope>
73+
</dependency>
74+
<dependency>
75+
<groupId>com.github.tomakehurst</groupId>
76+
<artifactId>wiremock</artifactId>
77+
<scope>test</scope>
78+
</dependency>
79+
</dependencies>
80+
<build>
81+
<plugins>
82+
<plugin>
83+
<groupId>org.apache.felix</groupId>
84+
<artifactId>maven-bundle-plugin</artifactId>
85+
<extensions>true</extensions>
86+
</plugin>
87+
<plugin>
88+
<groupId>org.apache.maven.plugins</groupId>
89+
<artifactId>maven-deploy-plugin</artifactId>
90+
<version>2.8.2</version>
91+
<configuration>
92+
<skip>true</skip>
93+
</configuration>
94+
</plugin>
95+
<plugin>
96+
<groupId>org.apache.maven.plugins</groupId>
97+
<artifactId>maven-assembly-plugin</artifactId>
98+
<executions>
99+
<execution>
100+
<phase>package</phase>
101+
<goals>
102+
<goal>single</goal>
103+
</goals>
104+
<configuration>
105+
<archive>
106+
<manifest>
107+
<mainClass>io.kubernetes.client.examples.Example</mainClass>
108+
</manifest>
109+
</archive>
110+
<descriptorRefs>
111+
<descriptorRef>jar-with-dependencies</descriptorRef>
112+
</descriptorRefs>
113+
</configuration>
114+
</execution>
115+
</executions>
116+
</plugin>
117+
</plugins>
118+
</build>
123119

124120
</project>

examples/examples-release-10/src/main/java/io/kubernetes/client/examples/AttachExample.java

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

15-
import com.google.common.io.ByteStreams;
1615
import io.kubernetes.client.Attach;
1716
import io.kubernetes.client.openapi.ApiClient;
1817
import io.kubernetes.client.openapi.ApiException;
@@ -62,7 +61,7 @@ public void run() {
6261
new Runnable() {
6362
public void run() {
6463
try {
65-
ByteStreams.copy(result.getStandardOutputStream(), System.out);
64+
Streams.copy(result.getStandardOutputStream(), System.out);
6665
} catch (IOException ex) {
6766
ex.printStackTrace();
6867
}

examples/examples-release-10/src/main/java/io/kubernetes/client/examples/CopyExample.java

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

15-
import com.google.common.io.ByteStreams;
1615
import io.kubernetes.client.Copy;
1716
import io.kubernetes.client.openapi.ApiClient;
1817
import io.kubernetes.client.openapi.ApiException;
@@ -42,7 +41,7 @@ public static void main(String[] args)
4241

4342
Copy copy = new Copy();
4443
InputStream dataStream = copy.copyFileFromPod(namespace, podName, "/etc/motd");
45-
ByteStreams.copy(dataStream, System.out);
44+
Streams.copy(dataStream, System.out);
4645

4746
copy.copyDirectoryFromPod(namespace, podName, null, "/etc", Paths.get("/tmp/etc"));
4847

examples/examples-release-10/src/main/java/io/kubernetes/client/examples/ExecExample.java

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

15-
import com.google.common.io.ByteStreams;
1615
import io.kubernetes.client.Exec;
1716
import io.kubernetes.client.openapi.ApiClient;
1817
import io.kubernetes.client.openapi.ApiException;
@@ -63,7 +62,7 @@ public static void main(String[] args)
6362
new Runnable() {
6463
public void run() {
6564
try {
66-
ByteStreams.copy(System.in, proc.getOutputStream());
65+
Streams.copy(System.in, proc.getOutputStream());
6766
} catch (IOException ex) {
6867
ex.printStackTrace();
6968
}
@@ -76,7 +75,7 @@ public void run() {
7675
new Runnable() {
7776
public void run() {
7877
try {
79-
ByteStreams.copy(proc.getInputStream(), System.out);
78+
Streams.copy(proc.getInputStream(), System.out);
8079
} catch (IOException ex) {
8180
ex.printStackTrace();
8281
}

examples/examples-release-10/src/main/java/io/kubernetes/client/examples/KubectlExample.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import static io.kubernetes.client.extended.kubectl.Kubectl.version;
2929
import static io.kubernetes.client.extended.kubectl.KubectlTop.podMetricSum;
3030

31-
import com.google.common.io.ByteStreams;
3231
import io.kubernetes.client.common.KubernetesObject;
3332
import io.kubernetes.client.custom.NodeMetrics;
3433
import io.kubernetes.client.custom.PodMetrics;
@@ -244,7 +243,7 @@ public static void main(String[] args)
244243
System.exit(0);
245244
case "log":
246245
name = args[1];
247-
ByteStreams.copy(
246+
Streams.copy(
248247
log()
249248
.apiClient(client)
250249
.name(name)

examples/examples-release-10/src/main/java/io/kubernetes/client/examples/LogsExample.java

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

15-
import com.google.common.io.ByteStreams;
1615
import io.kubernetes.client.PodLogs;
1716
import io.kubernetes.client.openapi.ApiClient;
1817
import io.kubernetes.client.openapi.ApiException;
@@ -45,6 +44,6 @@ public static void main(String[] args) throws IOException, ApiException, Interru
4544
.get(0);
4645

4746
InputStream is = logs.streamNamespacedPodLog(pod);
48-
ByteStreams.copy(is, System.out);
47+
Streams.copy(is, System.out);
4948
}
5049
}

examples/examples-release-10/src/main/java/io/kubernetes/client/examples/PortForwardExample.java

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

15-
import com.google.common.io.ByteStreams;
1615
import io.kubernetes.client.PortForward;
1716
import io.kubernetes.client.openapi.ApiClient;
1817
import io.kubernetes.client.openapi.ApiException;
@@ -56,7 +55,7 @@ public static void main(String[] args) throws IOException, ApiException, Interru
5655
new Runnable() {
5756
public void run() {
5857
try {
59-
ByteStreams.copy(result.getInputStream(targetPort), s.getOutputStream());
58+
Streams.copy(result.getInputStream(targetPort), s.getOutputStream());
6059
} catch (IOException ex) {
6160
ex.printStackTrace();
6261
} catch (Exception ex) {
@@ -70,7 +69,7 @@ public void run() {
7069
new Runnable() {
7170
public void run() {
7271
try {
73-
ByteStreams.copy(s.getInputStream(), result.getOutboundStream(targetPort));
72+
Streams.copy(s.getInputStream(), result.getOutboundStream(targetPort));
7473
} catch (IOException ex) {
7574
ex.printStackTrace();
7675
} catch (Exception ex) {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
Copyright 2020 The Kubernetes Authors.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
package io.kubernetes.client.examples;
14+
15+
import java.io.IOException;
16+
import java.io.InputStream;
17+
import java.io.OutputStream;
18+
19+
public class Streams {
20+
21+
public static final int BUFFER_SIZE = 4096;
22+
23+
public static void copy(InputStream in, OutputStream out) throws IOException {
24+
byte[] buffer = new byte[BUFFER_SIZE];
25+
int bytesRead;
26+
while ((bytesRead = in.read(buffer)) != -1) {
27+
out.write(buffer, 0, bytesRead);
28+
}
29+
out.flush();
30+
}
31+
}

examples/examples-release-11/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@
4848
<artifactId>client-java-proto</artifactId>
4949
<version>${kubernetes.client.version}</version>
5050
</dependency>
51-
<dependency>
52-
<groupId>com.google.guava</groupId>
53-
<artifactId>guava</artifactId>
54-
</dependency>
5551
<dependency>
5652
<groupId>commons-cli</groupId>
5753
<artifactId>commons-cli</artifactId>

0 commit comments

Comments
 (0)