correct order (discovery clean-up part-2) (#1497)

This commit is contained in:
erabii
2023-11-07 22:26:34 +02:00
committed by GitHub
parent 508433bb2c
commit 088e27a134
3 changed files with 9 additions and 7 deletions

View File

@@ -75,17 +75,17 @@ final class Fabric8KubernetesDiscoveryClientUtils {
List<Endpoints> endpoints;
if (properties.allNamespaces()) {
LOG.debug(() -> "discovering endpoints in all namespaces");
endpoints = filteredEndpoints(client.endpoints().inAnyNamespace().withNewFilter(), properties, serviceName);
}
else if (!properties.namespaces().isEmpty()) {
if (!properties.namespaces().isEmpty()) {
LOG.debug(() -> "discovering endpoints in namespaces : " + properties.namespaces());
List<Endpoints> inner = new ArrayList<>(properties.namespaces().size());
properties.namespaces().forEach(namespace -> inner.addAll(filteredEndpoints(
client.endpoints().inNamespace(namespace).withNewFilter(), properties, serviceName)));
endpoints = inner;
}
else if (properties.allNamespaces()) {
LOG.debug(() -> "discovering endpoints in all namespaces");
endpoints = filteredEndpoints(client.endpoints().inAnyNamespace().withNewFilter(), properties, serviceName);
}
else {
String namespace = Fabric8Utils.getApplicationNamespace(client, null, target, namespaceProvider);
LOG.debug(() -> "discovering endpoints in namespace : " + namespace);

View File

@@ -187,7 +187,9 @@ public class KubernetesDiscoveryClient implements DiscoveryClient, EnvironmentAw
@Override
public List<String> getServices() {
return adapter.apply(client).stream().map(s -> s.getMetadata().getName()).distinct().toList();
List<String> services = adapter.apply(client).stream().map(s -> s.getMetadata().getName()).distinct().toList();
LOG.debug(() -> "will return services : " + services);
return services;
}
@Deprecated(forRemoval = true)

View File

@@ -143,7 +143,7 @@ class Fabric8KubernetesCatalogWatchEndpointsTests extends Fabric8EndpointsAndEnd
@Override
void testAllNamespacesTrueOtherBranchesNotCalled() {
KubernetesCatalogWatch watch = createWatcherInAllNamespacesWithLabels(Map.of("color", "blue"), Set.of("B"),
KubernetesCatalogWatch watch = createWatcherInAllNamespacesWithLabels(Map.of("color", "blue"), Set.of(),
ENDPOINT_SLICES);
endpoints("namespaceA", Map.of(), "podA");