Skip to content

Commit ef7fdaf

Browse files
authored
Merge pull request #2134 from wind57/move-to-call-generator
move to call generator
2 parents bddc064 + c6acd43 commit ef7fdaf

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

spring-cloud-kubernetes-client-discovery/src/main/java/org/springframework/cloud/kubernetes/client/discovery/KubernetesClientConfigServerBootstrapper.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
import io.kubernetes.client.openapi.models.V1EndpointsList;
3030
import io.kubernetes.client.openapi.models.V1Service;
3131
import io.kubernetes.client.openapi.models.V1ServiceList;
32+
import io.kubernetes.client.util.CallGenerator;
3233
import io.kubernetes.client.util.Namespaces;
33-
import io.kubernetes.client.util.generic.GenericKubernetesApi;
3434
import org.apache.commons.logging.Log;
3535
import org.apache.commons.logging.LogFactory;
3636

@@ -47,6 +47,8 @@
4747
import org.springframework.core.env.Environment;
4848

4949
import static org.springframework.cloud.kubernetes.client.KubernetesClientUtils.kubernetesApiClient;
50+
import static org.springframework.cloud.kubernetes.client.discovery.KubernetesClientDiscoveryClientUtils.endpointsCallGenerator;
51+
import static org.springframework.cloud.kubernetes.client.discovery.KubernetesClientDiscoveryClientUtils.servicesCallGenerator;
5052

5153
/**
5254
* @author Ryan Baxter
@@ -81,24 +83,30 @@ public void initialize(BootstrapRegistry registry) {
8183
ApiClient defaultApiClient = kubernetesApiClient();
8284
defaultApiClient.setUserAgent(propertyResolver.get("spring.cloud.kubernetes.client.user-agent",
8385
String.class, KubernetesClientProperties.DEFAULT_USER_AGENT));
86+
8487
KubernetesClientAutoConfiguration clientAutoConfiguration = new KubernetesClientAutoConfiguration();
8588
ApiClient apiClient = context.getOrElseSupply(ApiClient.class, () -> defaultApiClient);
8689

8790
KubernetesNamespaceProvider kubernetesNamespaceProvider = clientAutoConfiguration
8891
.kubernetesNamespaceProvider(getNamespaceEnvironment(propertyResolver));
92+
8993
KubernetesDiscoveryProperties discoveryProperties = context.get(KubernetesDiscoveryProperties.class);
9094
String namespace = getInformerNamespace(kubernetesNamespaceProvider, discoveryProperties);
9195
SharedInformerFactory sharedInformerFactory = new SharedInformerFactory(apiClient);
92-
GenericKubernetesApi<V1Service, V1ServiceList> servicesApi = new GenericKubernetesApi<>(V1Service.class,
93-
V1ServiceList.class, "", "v1", "services", apiClient);
96+
CoreV1Api coreV1Api = new CoreV1Api(apiClient);
97+
98+
CallGenerator serviceCallGenerator = servicesCallGenerator(coreV1Api,
99+
discoveryProperties.serviceLabels(), namespace);
94100
SharedIndexInformer<V1Service> serviceSharedIndexInformer = sharedInformerFactory
95-
.sharedIndexInformerFor(servicesApi, V1Service.class, 0L, namespace);
101+
.sharedIndexInformerFor(serviceCallGenerator, V1Service.class, V1ServiceList.class);
96102
Lister<V1Service> serviceLister = new Lister<>(serviceSharedIndexInformer.getIndexer());
97-
GenericKubernetesApi<V1Endpoints, V1EndpointsList> endpointsApi = new GenericKubernetesApi<>(
98-
V1Endpoints.class, V1EndpointsList.class, "", "v1", "endpoints", apiClient);
103+
104+
CallGenerator endpointsCallGenerator = endpointsCallGenerator(coreV1Api,
105+
discoveryProperties.serviceLabels(), namespace);
99106
SharedIndexInformer<V1Endpoints> endpointsSharedIndexInformer = sharedInformerFactory
100-
.sharedIndexInformerFor(endpointsApi, V1Endpoints.class, 0L, namespace);
107+
.sharedIndexInformerFor(endpointsCallGenerator, V1Endpoints.class, V1EndpointsList.class);
101108
Lister<V1Endpoints> endpointsLister = new Lister<>(endpointsSharedIndexInformer.getIndexer());
109+
102110
Predicate<V1Service> predicate = x -> true;
103111
KubernetesClientInformerDiscoveryClient discoveryClient = new KubernetesClientInformerDiscoveryClient(
104112
List.of(sharedInformerFactory), List.of(serviceLister), List.of(endpointsLister),

0 commit comments

Comments
 (0)