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
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static List<EndpointNameAndNamespace> state(Stream<V1ObjectReference> references
}

static String labelSelector(Map<String, String> labels) {
return labels.entrySet().stream().map(en -> en.getKey() + "=" + en.getValue()).collect(Collectors.joining("&"));
return labels.entrySet().stream().map(en -> en.getKey() + "=" + en.getValue()).collect(Collectors.joining(","));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.springframework.cloud.kubernetes.client.discovery.catalog;

import java.util.LinkedHashMap;
import java.util.Map;

import org.junit.jupiter.api.Assertions;
Expand All @@ -40,10 +41,11 @@ void singleLabel() {

@Test
void multipleLabelsLabel() {
String result = KubernetesCatalogWatchContext.labelSelector(Map.of("a", "b", "c", "d"));
Assertions.assertTrue(result.contains("c=d"));
Assertions.assertTrue(result.contains("&"));
Assertions.assertTrue(result.contains("a=b"));
Map<String, String> labels = new LinkedHashMap<>();
labels.put("a", "b");
labels.put("c", "d");
String result = KubernetesCatalogWatchContext.labelSelector(labels);
Assertions.assertEquals("a=b,c=d", result);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void testInAllNamespacesWithSingleLabel() {
@Test
@Override
void testInAllNamespacesWithDoubleLabel() {
stubFor(get("/apis/discovery.k8s.io/v1/endpointslices?labelSelector=a%3Db%26c%3Dd")
stubFor(get("/apis/discovery.k8s.io/v1/endpointslices?labelSelector=a%3Db%2Cc%3Dd")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(endpointSlices("a", "default")))));
// otherwise the stub might fail
LinkedHashMap<String, String> map = new LinkedHashMap<>();
Expand Down Expand Up @@ -137,9 +137,9 @@ void testInSpecificNamespacesWithSingleLabel() {
@Test
@Override
void testInSpecificNamespacesWithDoubleLabel() {
stubFor(get("/apis/discovery.k8s.io/v1/namespaces/one/endpointslices?labelSelector=a%3Db%26c%3Dd")
stubFor(get("/apis/discovery.k8s.io/v1/namespaces/one/endpointslices?labelSelector=a%3Db%2Cc%3Dd")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(endpointSlices("aa", "a")))));
stubFor(get("/apis/discovery.k8s.io/v1/namespaces/two/endpointslices?labelSelector=a%3Db%26c%3Dd")
stubFor(get("/apis/discovery.k8s.io/v1/namespaces/two/endpointslices?labelSelector=a%3Db%2Cc%3Dd")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(endpointSlices("bb", "b")))));

// otherwise the stub might fail
Expand Down Expand Up @@ -179,7 +179,7 @@ void testInOneNamespaceWithSingleLabel() {
@Test
@Override
void testInOneNamespaceWithDoubleLabel() {
stubFor(get("/apis/discovery.k8s.io/v1/namespaces/b/endpointslices?labelSelector=key%3Dvalue%26key1%3Dvalue1")
stubFor(get("/apis/discovery.k8s.io/v1/namespaces/b/endpointslices?labelSelector=key%3Dvalue%2Ckey1%3Dvalue1")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(endpointSlices("a", "b")))));
// otherwise the stub might fail
LinkedHashMap<String, String> map = new LinkedHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void testInAllNamespacesWithSingleLabel() {
@Test
@Override
void testInAllNamespacesWithDoubleLabel() {
stubFor(get("/api/v1/endpoints?labelSelector=a%3Db%26c%3Dd")
stubFor(get("/api/v1/endpoints?labelSelector=a%3Db%2Cc%3Dd")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(endpoints("a", "default")))));
// otherwise the stub might fail
LinkedHashMap<String, String> map = new LinkedHashMap<>();
Expand Down Expand Up @@ -137,9 +137,9 @@ void testInSpecificNamespacesWithSingleLabel() {
@Test
@Override
void testInSpecificNamespacesWithDoubleLabel() {
stubFor(get("/api/v1/namespaces/one/endpoints?labelSelector=a%3Db%26c%3Dd")
stubFor(get("/api/v1/namespaces/one/endpoints?labelSelector=a%3Db%2Cc%3Dd")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(endpoints("aa", "a")))));
stubFor(get("/api/v1/namespaces/two/endpoints?labelSelector=a%3Db%26c%3Dd")
stubFor(get("/api/v1/namespaces/two/endpoints?labelSelector=a%3Db%2Cc%3Dd")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(endpoints("bb", "b")))));

// otherwise the stub might fail
Expand Down Expand Up @@ -179,7 +179,7 @@ void testInOneNamespaceWithSingleLabel() {
@Test
@Override
void testInOneNamespaceWithDoubleLabel() {
stubFor(get("/api/v1/namespaces/b/endpoints?labelSelector=key%3Dvalue%26key1%3Dvalue1")
stubFor(get("/api/v1/namespaces/b/endpoints?labelSelector=key%3Dvalue%2Ckey1%3Dvalue1")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(endpoints("a", "b")))));
// otherwise the stub might fail
LinkedHashMap<String, String> map = new LinkedHashMap<>();
Expand Down
Loading