Skip to content

Commit

Permalink
Merge pull request #1444 from dsyer/examples-guava
Browse files Browse the repository at this point in the history
Factor Guava out of examples
  • Loading branch information
k8s-ci-robot committed Dec 15, 2020
2 parents 49cf295 + 421dc32 commit 385b070
Show file tree
Hide file tree
Showing 17 changed files with 158 additions and 151 deletions.
212 changes: 104 additions & 108 deletions examples/examples-release-10/pom.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<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">
<modelVersion>4.0.0</modelVersion>
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.kubernetes</groupId>
<artifactId>client-java-examples-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<parent>
<groupId>io.kubernetes</groupId>
<artifactId>client-java-examples-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>client-java-examples-release-10</artifactId>
<packaging>bundle</packaging>
<name>client-java-examples-release-10</name>
<artifactId>client-java-examples-release-10</artifactId>
<packaging>bundle</packaging>
<name>client-java-examples-release-10</name>

<properties>
<kubernetes.client.version>10.0.0</kubernetes.client.version>
</properties>
<dependencies>
<properties>
<kubernetes.client.version>10.0.0</kubernetes.client.version>
</properties>
<dependencies>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient</artifactId>
Expand All @@ -26,99 +26,95 @@
<artifactId>simpleclient_httpserver</artifactId>
<version>0.9.0</version>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java-api</artifactId>
<version>${kubernetes.client.version}</version>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java</artifactId>
<version>${kubernetes.client.version}</version>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java-extended</artifactId>
<version>${kubernetes.client.version}</version>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java-spring-integration</artifactId>
<version>${kubernetes.client.version}</version>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java-proto</artifactId>
<version>${kubernetes.client.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java-cert-manager-models</artifactId>
<version>10.0.0</version>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java-prometheus-operator-models</artifactId>
<version>10.0.0</version>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>io.kubernetes.client.examples.Example</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java-api</artifactId>
<version>${kubernetes.client.version}</version>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java</artifactId>
<version>${kubernetes.client.version}</version>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java-extended</artifactId>
<version>${kubernetes.client.version}</version>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java-spring-integration</artifactId>
<version>${kubernetes.client.version}</version>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java-proto</artifactId>
<version>${kubernetes.client.version}</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java-cert-manager-models</artifactId>
<version>10.0.0</version>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java-prometheus-operator-models</artifactId>
<version>10.0.0</version>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>io.kubernetes.client.examples.Example</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
package io.kubernetes.client.examples;

import com.google.common.io.ByteStreams;
import io.kubernetes.client.Attach;
import io.kubernetes.client.openapi.ApiClient;
import io.kubernetes.client.openapi.ApiException;
Expand Down Expand Up @@ -62,7 +61,7 @@ public void run() {
new Runnable() {
public void run() {
try {
ByteStreams.copy(result.getStandardOutputStream(), System.out);
Streams.copy(result.getStandardOutputStream(), System.out);
} catch (IOException ex) {
ex.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
package io.kubernetes.client.examples;

import com.google.common.io.ByteStreams;
import io.kubernetes.client.Copy;
import io.kubernetes.client.openapi.ApiClient;
import io.kubernetes.client.openapi.ApiException;
Expand Down Expand Up @@ -42,7 +41,7 @@ public static void main(String[] args)

Copy copy = new Copy();
InputStream dataStream = copy.copyFileFromPod(namespace, podName, "/etc/motd");
ByteStreams.copy(dataStream, System.out);
Streams.copy(dataStream, System.out);

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
package io.kubernetes.client.examples;

import com.google.common.io.ByteStreams;
import io.kubernetes.client.Exec;
import io.kubernetes.client.openapi.ApiClient;
import io.kubernetes.client.openapi.ApiException;
Expand Down Expand Up @@ -63,7 +62,7 @@ public static void main(String[] args)
new Runnable() {
public void run() {
try {
ByteStreams.copy(System.in, proc.getOutputStream());
Streams.copy(System.in, proc.getOutputStream());
} catch (IOException ex) {
ex.printStackTrace();
}
Expand All @@ -76,7 +75,7 @@ public void run() {
new Runnable() {
public void run() {
try {
ByteStreams.copy(proc.getInputStream(), System.out);
Streams.copy(proc.getInputStream(), System.out);
} catch (IOException ex) {
ex.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import static io.kubernetes.client.extended.kubectl.Kubectl.version;
import static io.kubernetes.client.extended.kubectl.KubectlTop.podMetricSum;

import com.google.common.io.ByteStreams;
import io.kubernetes.client.common.KubernetesObject;
import io.kubernetes.client.custom.NodeMetrics;
import io.kubernetes.client.custom.PodMetrics;
Expand Down Expand Up @@ -244,7 +243,7 @@ public static void main(String[] args)
System.exit(0);
case "log":
name = args[1];
ByteStreams.copy(
Streams.copy(
log()
.apiClient(client)
.name(name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
package io.kubernetes.client.examples;

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

InputStream is = logs.streamNamespacedPodLog(pod);
ByteStreams.copy(is, System.out);
Streams.copy(is, System.out);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
package io.kubernetes.client.examples;

import com.google.common.io.ByteStreams;
import io.kubernetes.client.PortForward;
import io.kubernetes.client.openapi.ApiClient;
import io.kubernetes.client.openapi.ApiException;
Expand Down Expand Up @@ -56,7 +55,7 @@ public static void main(String[] args) throws IOException, ApiException, Interru
new Runnable() {
public void run() {
try {
ByteStreams.copy(result.getInputStream(targetPort), s.getOutputStream());
Streams.copy(result.getInputStream(targetPort), s.getOutputStream());
} catch (IOException ex) {
ex.printStackTrace();
} catch (Exception ex) {
Expand All @@ -70,7 +69,7 @@ public void run() {
new Runnable() {
public void run() {
try {
ByteStreams.copy(s.getInputStream(), result.getOutboundStream(targetPort));
Streams.copy(s.getInputStream(), result.getOutboundStream(targetPort));
} catch (IOException ex) {
ex.printStackTrace();
} catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Copyright 2020 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package io.kubernetes.client.examples;

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

public class Streams {

public static final int BUFFER_SIZE = 4096;

public static void copy(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[BUFFER_SIZE];
int bytesRead;
while ((bytesRead = in.read(buffer)) != -1) {
out.write(buffer, 0, bytesRead);
}
out.flush();
}
}
4 changes: 0 additions & 4 deletions examples/examples-release-11/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@
<artifactId>client-java-proto</artifactId>
<version>${kubernetes.client.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
Expand Down

0 comments on commit 385b070

Please sign in to comment.