Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

* Updated jackson to 2.9.8

* Upgrade okhttp to 3.12.0

New Feature

* Fix #1286: Pod Preset Support
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ public WatchConnectionManager(final OkHttpClient client, final BaseOperation<T,
this.websocketTimeout = websocketTimeout;
this.maxIntervalExponent = maxIntervalExponent;

this.clonedClient = client.newBuilder().readTimeout(this.websocketTimeout, TimeUnit.MILLISECONDS).build();
this.clonedClient = client.newBuilder()
.pingInterval(30, TimeUnit.SECONDS)
.readTimeout(this.websocketTimeout, TimeUnit.MILLISECONDS)
.build();

// The URL is created, validated and saved once, so that reconnect attempts don't have to deal with
// MalformedURLExceptions that would never occur
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
import java.io.Closeable;
import java.io.Flushable;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -293,4 +295,19 @@ public static String getProperty(Map<String, Object> properties, String property
public static String getProperty(Map<String, Object> properties, String propertyName) {
return getProperty(properties, propertyName, null);
}

/**
* Converts string to URL encoded string.
*
* @param str
* @return
*/
public static final String toUrlEncoded(String str) {
try {
return URLEncoder.encode(str, "UTF-8");
} catch (UnsupportedEncodingException exception) {
// Ignore
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientException;
import io.fabric8.kubernetes.client.server.mock.KubernetesServer;
import io.fabric8.kubernetes.client.utils.Utils;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -63,8 +64,8 @@ public void testList() {

@Test
public void testListWithLables() {
server.expect().withPath("/apis/batch/v1beta1/namespaces/test/cronjobs?labelSelector=" + toUrlEncoded("key1=value1,key2=value2,key3=value3")).andReturn(200, new CronJobListBuilder().build()).always();
server.expect().withPath("/apis/batch/v1beta1/namespaces/test/cronjobs?labelSelector=" + toUrlEncoded("key1=value1,key2=value2")).andReturn(200, new CronJobListBuilder()
server.expect().withPath("/apis/batch/v1beta1/namespaces/test/cronjobs?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2,key3=value3")).andReturn(200, new CronJobListBuilder().build()).always();
server.expect().withPath("/apis/batch/v1beta1/namespaces/test/cronjobs?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2")).andReturn(200, new CronJobListBuilder()
.addNewItem().and()
.addNewItem().and()
.addNewItem().and()
Expand Down Expand Up @@ -252,14 +253,4 @@ public void testHandlersLoadFromFile() {
assertTrue("Handler did not return expected single resource", 1==hasMetadata.size());
assertEquals("hasMetadata found did not match the expected name of the test input", "pi", hasMetadata.get(0).getMetadata().getName());
}

/**
* Converts string to URL encoded string.
* It's not a full blown converter, it serves just the purpose of this test.
* @param str
* @return
*/
private static final String toUrlEncoded(String str) {
return str.replaceAll("=", "%3D");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.fabric8.kubernetes.client.KubernetesClientException;
import io.fabric8.kubernetes.client.server.mock.KubernetesServer;

import io.fabric8.kubernetes.client.utils.Utils;
import org.junit.Rule;
import org.junit.Test;

Expand Down Expand Up @@ -69,8 +70,8 @@ public void testList() {

@Test
public void testListWithLabels() {
server.expect().withPath("/apis/apps/v1/namespaces/test/deployments?labelSelector=" + toUrlEncoded("key1=value1,key2=value2,key3=value3")).andReturn(200, new DeploymentListBuilder().build()).always();
server.expect().withPath("/apis/apps/v1/namespaces/test/deployments?labelSelector=" + toUrlEncoded("key1=value1,key2=value2")).andReturn(200, new DeploymentListBuilder()
server.expect().withPath("/apis/apps/v1/namespaces/test/deployments?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2,key3=value3")).andReturn(200, new DeploymentListBuilder().build()).always();
server.expect().withPath("/apis/apps/v1/namespaces/test/deployments?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2")).andReturn(200, new DeploymentListBuilder()
.addNewItem().and()
.addNewItem().and()
.addNewItem().and()
Expand Down Expand Up @@ -271,14 +272,4 @@ public void testCreateWithNameMismatch() {

client.apps().deployments().inNamespace("test1").withName("mydeployment1").create(deployment1);
}

/**
* Converts string to URL encoded string.
* It's not a fullblown converter, it serves just the purpose of this test.
* @param str
* @return
*/
private static final String toUrlEncoded(String str) {
return str.replaceAll("=", "%3D");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientException;
import io.fabric8.kubernetes.client.server.mock.KubernetesServer;
import io.fabric8.kubernetes.client.utils.Utils;
import org.junit.Rule;
import org.junit.Test;

Expand Down Expand Up @@ -66,8 +67,8 @@ public void testList() {

@Test
public void testListWithLables() {
server.expect().withPath("/apis/extensions/v1beta1/namespaces/test/ingresses?labelSelector=" + toUrlEncoded("key1=value1,key2=value2,key3=value3")).andReturn(200, new IngressListBuilder().build()).always();
server.expect().withPath("/apis/extensions/v1beta1/namespaces/test/ingresses?labelSelector=" + toUrlEncoded("key1=value1,key2=value2")).andReturn(200, new IngressListBuilder()
server.expect().withPath("/apis/extensions/v1beta1/namespaces/test/ingresses?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2,key3=value3")).andReturn(200, new IngressListBuilder().build()).always();
server.expect().withPath("/apis/extensions/v1beta1/namespaces/test/ingresses?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2")).andReturn(200, new IngressListBuilder()
.addNewItem().and()
.addNewItem().and()
.addNewItem().and()
Expand Down Expand Up @@ -167,14 +168,4 @@ public void testCreateWithNameMismatch() {
client.extensions().ingress().inNamespace("test1").withName("myingress1").create(ingress1);
}

/**
* Converts string to URL encoded string.
* It's not a fullblown converter, it serves just the purpose of this test.
* @param str
* @return
*/
private static final String toUrlEncoded(String str) {
return str.replaceAll("=", "%3D");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientException;
import io.fabric8.kubernetes.client.server.mock.KubernetesServer;
import io.fabric8.kubernetes.client.utils.Utils;
import org.junit.Rule;
import org.junit.Test;

Expand Down Expand Up @@ -66,8 +67,8 @@ public void testList() {

@Test
public void testListWithLables() {
server.expect().withPath("/apis/batch/v1/namespaces/test/jobs?labelSelector=" + toUrlEncoded("key1=value1,key2=value2,key3=value3")).andReturn(200, new JobListBuilder().build()).always();
server.expect().withPath("/apis/batch/v1/namespaces/test/jobs?labelSelector=" + toUrlEncoded("key1=value1,key2=value2")).andReturn(200, new JobListBuilder()
server.expect().withPath("/apis/batch/v1/namespaces/test/jobs?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2,key3=value3")).andReturn(200, new JobListBuilder().build()).always();
server.expect().withPath("/apis/batch/v1/namespaces/test/jobs?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2")).andReturn(200, new JobListBuilder()
.addNewItem().and()
.addNewItem().and()
.addNewItem().and()
Expand Down Expand Up @@ -232,14 +233,4 @@ public void testCreateWithNameMismatch() {

client.batch().jobs().inNamespace("test1").withName("myjob1").create(job1);
}

/**
* Converts string to URL encoded string.
* It's not a fullblown converter, it serves just the purpose of this test.
* @param str
* @return
*/
private static final String toUrlEncoded(String str) {
return str.replaceAll("=", "%3D");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientException;
import io.fabric8.kubernetes.client.server.mock.KubernetesServer;
import io.fabric8.kubernetes.client.utils.Utils;
import org.junit.Rule;
import org.junit.Test;

Expand Down Expand Up @@ -66,8 +67,8 @@ public void list() {

@Test
public void testListWithLabels() {
server.expect().withPath("/apis/policy/v1beta1/namespaces/test/poddisruptionbudgets?labelSelector=" + toUrlEncoded("key1=value1,key2=value2,key3=value3")).andReturn(200, new PodDisruptionBudgetListBuilder().build()).always();
server.expect().withPath("/apis/policy/v1beta1/namespaces/test/poddisruptionbudgets?labelSelector=" + toUrlEncoded("key1=value1,key2=value2")).andReturn(200, new PodDisruptionBudgetListBuilder()
server.expect().withPath("/apis/policy/v1beta1/namespaces/test/poddisruptionbudgets?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2,key3=value3")).andReturn(200, new PodDisruptionBudgetListBuilder().build()).always();
server.expect().withPath("/apis/policy/v1beta1/namespaces/test/poddisruptionbudgets?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2")).andReturn(200, new PodDisruptionBudgetListBuilder()
.addNewItem().and()
.addNewItem().and()
.addNewItem().and()
Expand Down Expand Up @@ -151,15 +152,4 @@ public void testLoadFromFile() {
KubernetesClient client = server.getClient();
assertNotNull(client.policy().podDisruptionBudget().load(getClass().getResourceAsStream("/test-pdb.yml")).get());
}

/**
* Converts string to URL encoded string.
* It's not a full blown converter, it serves just the purpose of this test.
*
* @param str
* @return
*/
private static final String toUrlEncoded(String str) {
return str.replaceAll("=", "%3D");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.fabric8.kubernetes.client.mock;

import io.fabric8.kubernetes.client.utils.Utils;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -92,8 +93,8 @@ public void testList() {

@Test
public void testListWithLables() {
server.expect().withPath("/api/v1/namespaces/test/pods?labelSelector=" + toUrlEncoded("key1=value1,key2=value2,key3=value3")).andReturn(200, new PodListBuilder().build()).always();
server.expect().withPath("/api/v1/namespaces/test/pods?labelSelector=" + toUrlEncoded("key1=value1,key2=value2")).andReturn(200, new PodListBuilder()
server.expect().withPath("/api/v1/namespaces/test/pods?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2,key3=value3")).andReturn(200, new PodListBuilder().build()).always();
server.expect().withPath("/api/v1/namespaces/test/pods?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2")).andReturn(200, new PodListBuilder()
.addNewItem().and()
.addNewItem().and()
.addNewItem().and()
Expand Down Expand Up @@ -428,16 +429,6 @@ public void testPortForwardWithChannel() throws InterruptedException, IOExceptio
assertEquals("Hello World!", got);
}

/**
* Converts string to URL encoded string.
* It's not a fullblown converter, it serves just the purpose of this test.
* @param str
* @return
*/
private static final String toUrlEncoded(String str) {
return str.replaceAll("=", "%3D");
}

private static String portForwardEncode(boolean dataChannel, String str) {
try {
byte[] data = str.getBytes("UTF-8");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientException;
import io.fabric8.kubernetes.client.server.mock.KubernetesServer;
import io.fabric8.kubernetes.client.utils.Utils;
import org.junit.Rule;
import org.junit.Test;

Expand Down Expand Up @@ -51,8 +52,8 @@ public void testList() {

@Test
public void testListWithLables() {
server.expect().withPath("/apis/scheduling.k8s.io/v1beta1/priorityclasses?labelSelector=" + toUrlEncoded("key1=value1,key2=value2,key3=value3")).andReturn(200, new PriorityClassListBuilder().build()).always();
server.expect().withPath("/apis/scheduling.k8s.io/v1beta1/priorityclasses?labelSelector=" + toUrlEncoded("key1=value1,key2=value2")).andReturn(200, new PriorityClassListBuilder()
server.expect().withPath("/apis/scheduling.k8s.io/v1beta1/priorityclasses?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2,key3=value3")).andReturn(200, new PriorityClassListBuilder().build()).always();
server.expect().withPath("/apis/scheduling.k8s.io/v1beta1/priorityclasses?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2")).andReturn(200, new PriorityClassListBuilder()
.addNewItem().and()
.addNewItem().and()
.addNewItem().and()
Expand Down Expand Up @@ -146,14 +147,4 @@ public void testLoadFromFile() {
KubernetesClient client = server.getClient();
assertNotNull(client.scheduling().priorityClass().load(getClass().getResourceAsStream("/test-priorityclass.yml")).get());
}

/**
* Converts string to URL encoded string.
* It's not a full blown converter, it serves just the purpose of this test.
* @param str
* @return
*/
private static final String toUrlEncoded(String str) {
return str.replaceAll("=", "%3D");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ public void testBinaryBuildWithTimeout() {
@Test
public void testDelete() {
server.expect().withPath("/oapi/v1/namespaces/test/buildconfigs/bc1").andReturn(200, new BuildConfigBuilder().withNewMetadata().withName("bc1").and().build()).once();
server.expect().withPath("/oapi/v1/namespaces/test/builds?labelSelector=openshift.io/build-config.name%3Dbc1").andReturn( 200, new BuildListBuilder().build()).once();
server.expect().withPath("/oapi/v1/namespaces/test/builds?labelSelector=openshift.io%2Fbuild-config.name%3Dbc1").andReturn( 200, new BuildListBuilder().build()).once();
server.expect().withPath("/oapi/v1/namespaces/ns1/buildconfigs/bc2").andReturn( 200, new BuildConfigBuilder().withNewMetadata().withName("bc2").and().build()).once();
server.expect().withPath("/oapi/v1/namespaces/ns1/builds?labelSelector=openshift.io/build-config.name%3Dbc2").andReturn( 200, new BuildListBuilder().build()).once();
server.expect().withPath("/oapi/v1/namespaces/ns1/builds?labelSelector=openshift.io%2Fbuild-config.name%3Dbc2").andReturn( 200, new BuildListBuilder().build()).once();

OpenShiftClient client = server.getOpenshiftClient();

Expand Down
6 changes: 4 additions & 2 deletions platforms/karaf/features/src/main/resources/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@

<feature name="kubernetes-client" description="Fabric8 Kubernetes Client" version="${project.version}">
<bundle dependency='true'>mvn:javax.validation/validation-api/${validation.api.version}</bundle>
<bundle dependency='true'>mvn:com.fasterxml.jackson.core/jackson-core/${jackson.bundle.version}</bundle>
<bundle dependency='true'>mvn:com.google.code.findbugs/jsr305/${jsr305.version}</bundle>
<bundle dependency='true'>mvn:com.fasterxml.jackson.core/jackson-core/${jackson.version}</bundle>
<bundle dependency='true'>mvn:com.fasterxml.jackson.core/jackson-annotations/${jackson.bundle.version}</bundle>
<bundle dependency='true'>mvn:com.fasterxml.jackson.core/jackson-databind/${jackson.bundle.version}</bundle>
<bundle dependency='true'>mvn:com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/${jackson.bundle.version}</bundle>
<bundle dependency='true'>mvn:org.yaml/snakeyaml/${snakeyaml.version}</bundle>
<bundle dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.generex/${generex.bundle.version}</bundle>
<bundle dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.automaton/${automaton.bundle.version}</bundle>
<bundle dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.okio/${okio.bundle.version}</bundle>
<bundle dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.conscrypt-openjdk/${conscrypt-openjdk-uber.bundle.version}</bundle>
<bundle dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.okhttp/${okhttp.bundle.version}</bundle>
<bundle dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.okio/${okio.bundle.version}</bundle>
<bundle>mvn:io.fabric8/zjsonpatch/${zjsonpatch.version}</bundle>
<bundle>mvn:io.fabric8/kubernetes-model/${project.version}</bundle>
<bundle>mvn:io.fabric8/kubernetes-client/${project.version}/jar/bundle</bundle>
Expand Down
17 changes: 10 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,15 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mockwebserver.version>0.1.0</mockwebserver.version>
<okhttp.version>3.9.1</okhttp.version>
<okhttp.bundle.version>3.9.1_2</okhttp.bundle.version>
<okio.version>1.13.0</okio.version>
<okio.bundle.version>1.13.0_1</okio.bundle.version>
<mockwebserver.version>0.1.1</mockwebserver.version>
<okhttp.version>3.12.0</okhttp.version>
<okhttp.bundle.version>3.12.0_1</okhttp.bundle.version>
<okio.version>1.15.0</okio.version>
<okio.bundle.version>1.15.0_1</okio.bundle.version>
<jsr305.version>3.0.2</jsr305.version>
<retrofit.bundle.version>2.5.0_1</retrofit.bundle.version>
<conscrypt-openjdk-uber.version>1.4.2</conscrypt-openjdk-uber.version>
<conscrypt-openjdk-uber.bundle.version>1.4.2_1</conscrypt-openjdk-uber.bundle.version>
<generex.version>1.0.1</generex.version>
<generex.bundle.version>1.0.1_1</generex.bundle.version>
<automaton.version>1.11-8</automaton.version>
Expand All @@ -102,8 +106,7 @@

<scr.annotations.version>1.9.12</scr.annotations.version>
<sundrio.version>0.14.6</sundrio.version>
<validation.api.version>1.1.0.Final</validation.api.version>

<validation.api.version>2.0.1.Final</validation.api.version>
<maven.bundle.plugin.version>2.5.4</maven.bundle.plugin.version>
<maven.buildhelper.plugin.version>1.10</maven.buildhelper.plugin.version>
<maven.jar.plugin.version>3.0.1</maven.jar.plugin.version>
Expand Down