Skip to content

Commit c59623f

Browse files
committed
Fix generic watches.
1 parent dd06710 commit c59623f

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

util/src/main/java/io/kubernetes/client/util/generic/GenericKubernetesApi.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,9 +661,10 @@ public Watchable<ApiType> watch(String namespace, final ListOptions listOptions)
661661
throw new IllegalArgumentException("invalid namespace");
662662
}
663663
Call call =
664-
customObjectsApi.listClusterCustomObjectCall(
664+
customObjectsApi.listNamespacedCustomObjectCall(
665665
this.apiGroup,
666666
this.apiVersion,
667+
namespace,
667668
this.resourcePlural,
668669
null,
669670
listOptions.getContinue(),

util/src/test/java/io/kubernetes/client/util/generic/GenericKubernetesApiTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@
1919
import com.google.gson.Gson;
2020
import io.kubernetes.client.custom.V1Patch;
2121
import io.kubernetes.client.openapi.ApiClient;
22+
import io.kubernetes.client.openapi.ApiException;
2223
import io.kubernetes.client.openapi.models.*;
2324
import io.kubernetes.client.util.ClientBuilder;
25+
import io.kubernetes.client.util.Watchable;
26+
import io.kubernetes.client.util.generic.options.ListOptions;
2427
import java.io.IOException;
2528
import java.net.SocketTimeoutException;
2629
import java.util.concurrent.TimeUnit;
@@ -163,6 +166,20 @@ public void patchNamespacedJobReturningObject() {
163166
verify(1, patchRequestedFor(urlPathEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1")));
164167
}
165168

169+
@Test
170+
public void watchNamespacedJobReturningObject() throws ApiException {
171+
V1JobList jobList = new V1JobList().kind("JobList").metadata(new V1ListMeta());
172+
173+
stubFor(
174+
get(urlPathEqualTo("/apis/batch/v1/namespaces/default/jobs"))
175+
.willReturn(aResponse().withStatus(200).withBody(new Gson().toJson(jobList))));
176+
Watchable<V1Job> jobListWatch = jobClient.watch("default", new ListOptions());
177+
verify(
178+
1,
179+
getRequestedFor(urlPathEqualTo("/apis/batch/v1/namespaces/default/jobs"))
180+
.withQueryParam("watch", equalTo("true")));
181+
}
182+
166183
@Test
167184
public void testReadTimeoutShouldThrowException() {
168185
ApiClient apiClient = new ClientBuilder().setBasePath("http://localhost:" + 8181).build();

0 commit comments

Comments
 (0)