Skip to content

Commit 3f32573

Browse files
author
Dave Syer
committed
Apply source code formatter
Signed-off-by: Dave Syer <[email protected]>
1 parent 4cfb21a commit 3f32573

File tree

3 files changed

+63
-65
lines changed

3 files changed

+63
-65
lines changed

examples/examples-release-13/src/main/java/io/kubernetes/client/examples/SpringControllerExample.java

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,6 @@
1212
*/
1313
package io.kubernetes.client.examples;
1414

15-
import java.time.Duration;
16-
17-
import org.springframework.beans.factory.annotation.Autowired;
18-
import org.springframework.beans.factory.annotation.Value;
19-
import org.springframework.boot.CommandLineRunner;
20-
import org.springframework.boot.SpringApplication;
21-
import org.springframework.boot.autoconfigure.SpringBootApplication;
22-
import org.springframework.context.annotation.Bean;
23-
import org.springframework.context.annotation.Configuration;
24-
import org.springframework.stereotype.Component;
25-
2615
import io.kubernetes.client.extended.controller.Controller;
2716
import io.kubernetes.client.extended.controller.builder.ControllerBuilder;
2817
import io.kubernetes.client.extended.controller.builder.DefaultControllerBuilder;
@@ -41,6 +30,14 @@
4130
import io.kubernetes.client.openapi.models.V1Pod;
4231
import io.kubernetes.client.openapi.models.V1PodList;
4332
import io.kubernetes.client.util.generic.GenericKubernetesApi;
33+
import java.time.Duration;
34+
import org.springframework.beans.factory.annotation.Value;
35+
import org.springframework.boot.CommandLineRunner;
36+
import org.springframework.boot.SpringApplication;
37+
import org.springframework.boot.autoconfigure.SpringBootApplication;
38+
import org.springframework.context.annotation.Bean;
39+
import org.springframework.context.annotation.Configuration;
40+
import org.springframework.stereotype.Component;
4441

4542
@SpringBootApplication
4643
public class SpringControllerExample {
@@ -53,8 +50,8 @@ public static void main(String[] args) {
5350
public static class AppConfig {
5451

5552
@Bean
56-
public CommandLineRunner commandLineRunner(SharedInformerFactory sharedInformerFactory,
57-
Controller nodePrintingController) {
53+
public CommandLineRunner commandLineRunner(
54+
SharedInformerFactory sharedInformerFactory, Controller nodePrintingController) {
5855
return args -> {
5956
System.out.println("starting informers..");
6057
sharedInformerFactory.startAllRegisteredInformers();
@@ -65,40 +62,45 @@ public CommandLineRunner commandLineRunner(SharedInformerFactory sharedInformerF
6562
}
6663

6764
@Bean
68-
public Controller nodePrintingController(SharedInformerFactory sharedInformerFactory,
69-
NodePrintingReconciler reconciler) {
65+
public Controller nodePrintingController(
66+
SharedInformerFactory sharedInformerFactory, NodePrintingReconciler reconciler) {
7067
DefaultControllerBuilder builder = ControllerBuilder.defaultBuilder(sharedInformerFactory);
71-
builder = builder.watch((q) -> {
72-
return ControllerBuilder.controllerWatchBuilder(V1Node.class, q).withResyncPeriod(Duration.ofMinutes(1))
73-
.build();
74-
});
68+
builder =
69+
builder.watch(
70+
(q) -> {
71+
return ControllerBuilder.controllerWatchBuilder(V1Node.class, q)
72+
.withResyncPeriod(Duration.ofMinutes(1))
73+
.build();
74+
});
7575
builder.withWorkerCount(2);
7676
builder.withReadyFunc(reconciler::informerReady);
7777
return builder.withReconciler(reconciler).withName("nodePrintingController").build();
7878
}
7979

8080
@Bean
81-
public SharedIndexInformer<V1Endpoints> endpointsInformer(ApiClient apiClient,
82-
SharedInformerFactory sharedInformerFactory) {
83-
GenericKubernetesApi<V1Endpoints, V1EndpointsList> genericApi = new GenericKubernetesApi<>(V1Endpoints.class,
84-
V1EndpointsList.class, "", "v1", "endpoints", apiClient);
85-
return sharedInformerFactory.sharedIndexInformerFor( genericApi , V1Endpoints.class, 0);
81+
public SharedIndexInformer<V1Endpoints> endpointsInformer(
82+
ApiClient apiClient, SharedInformerFactory sharedInformerFactory) {
83+
GenericKubernetesApi<V1Endpoints, V1EndpointsList> genericApi =
84+
new GenericKubernetesApi<>(
85+
V1Endpoints.class, V1EndpointsList.class, "", "v1", "endpoints", apiClient);
86+
return sharedInformerFactory.sharedIndexInformerFor(genericApi, V1Endpoints.class, 0);
8687
}
8788

8889
@Bean
89-
public SharedIndexInformer<V1Node> nodeInformer(ApiClient apiClient, SharedInformerFactory sharedInformerFactory) {
90-
GenericKubernetesApi<V1Node, V1NodeList> genericApi = new GenericKubernetesApi<>(V1Node.class,
91-
V1NodeList.class, "", "v1", "nodes", apiClient);
92-
return sharedInformerFactory.sharedIndexInformerFor( genericApi , V1Node.class, 60 * 1000L);
90+
public SharedIndexInformer<V1Node> nodeInformer(
91+
ApiClient apiClient, SharedInformerFactory sharedInformerFactory) {
92+
GenericKubernetesApi<V1Node, V1NodeList> genericApi =
93+
new GenericKubernetesApi<>(V1Node.class, V1NodeList.class, "", "v1", "nodes", apiClient);
94+
return sharedInformerFactory.sharedIndexInformerFor(genericApi, V1Node.class, 60 * 1000L);
9395
}
9496

9597
@Bean
96-
public SharedIndexInformer<V1Pod> podInformer(ApiClient apiClient, SharedInformerFactory sharedInformerFactory) {
97-
GenericKubernetesApi<V1Pod, V1PodList> genericApi = new GenericKubernetesApi<>(V1Pod.class, V1PodList.class,
98-
"", "v1", "pods", apiClient);
99-
return sharedInformerFactory.sharedIndexInformerFor( genericApi , V1Pod.class, 0);
98+
public SharedIndexInformer<V1Pod> podInformer(
99+
ApiClient apiClient, SharedInformerFactory sharedInformerFactory) {
100+
GenericKubernetesApi<V1Pod, V1PodList> genericApi =
101+
new GenericKubernetesApi<>(V1Pod.class, V1PodList.class, "", "v1", "pods", apiClient);
102+
return sharedInformerFactory.sharedIndexInformerFor(genericApi, V1Pod.class, 0);
100103
}
101-
102104
}
103105

104106
@Component
@@ -115,7 +117,8 @@ public static class NodePrintingReconciler implements Reconciler {
115117

116118
private Lister<V1Pod> podLister;
117119

118-
public NodePrintingReconciler(SharedIndexInformer<V1Node> nodeInformer, SharedIndexInformer<V1Pod> podInformer) {
120+
public NodePrintingReconciler(
121+
SharedIndexInformer<V1Node> nodeInformer, SharedIndexInformer<V1Pod> podInformer) {
119122
this.nodeInformer = nodeInformer;
120123
this.podInformer = podInformer;
121124
this.nodeLister = new Lister<>(nodeInformer.getIndexer(), namespace);
@@ -133,7 +136,8 @@ public Result reconcile(Request request) {
133136
V1Node node = nodeLister.get(request.getName());
134137

135138
System.out.println("get all pods in namespace " + namespace);
136-
podLister.namespace(namespace).list().stream().map(pod -> pod.getMetadata().getName())
139+
podLister.namespace(namespace).list().stream()
140+
.map(pod -> pod.getMetadata().getName())
137141
.forEach(System.out::println);
138142

139143
System.out.println("triggered reconciling " + node.getMetadata().getName());

spring/src/main/java/io/kubernetes/client/spring/extended/controller/config/KubernetesInformerAutoConfiguration.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,15 @@
1212
*/
1313
package io.kubernetes.client.spring.extended.controller.config;
1414

15+
import io.kubernetes.client.informer.SharedInformerFactory;
16+
import io.kubernetes.client.openapi.ApiClient;
17+
import io.kubernetes.client.util.ClientBuilder;
1518
import java.io.IOException;
16-
1719
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
1820
import org.springframework.boot.context.properties.EnableConfigurationProperties;
1921
import org.springframework.context.annotation.Bean;
2022
import org.springframework.context.annotation.Configuration;
2123

22-
import io.kubernetes.client.informer.SharedInformerFactory;
23-
import io.kubernetes.client.openapi.ApiClient;
24-
import io.kubernetes.client.util.ClientBuilder;
25-
2624
@Configuration(proxyBeanMethods = false)
2725
@ConditionalOnKubernetesInformerEnabled
2826
@EnableConfigurationProperties({
@@ -41,5 +39,4 @@ public ApiClient defaultApiClient() throws IOException {
4139
public SharedInformerFactory sharedInformerFactory() {
4240
return new SharedInformerFactory();
4341
}
44-
4542
}

spring/src/test/java/io/kubernetes/client/spring/extended/controller/KubernetesInformerCreatorTest.java

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,8 @@
2222
import static org.junit.Assert.assertEquals;
2323
import static org.junit.Assert.assertNotNull;
2424

25-
import java.util.Arrays;
26-
2725
import com.github.tomakehurst.wiremock.junit.WireMockRule;
2826
import com.google.gson.Gson;
29-
<<<<<<< HEAD
30-
=======
31-
32-
import org.junit.Rule;
33-
import org.junit.Test;
34-
import org.junit.runner.RunWith;
35-
import org.springframework.beans.factory.annotation.Autowired;
36-
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
37-
import org.springframework.boot.autoconfigure.SpringBootApplication;
38-
import org.springframework.boot.test.context.SpringBootTest;
39-
import org.springframework.context.annotation.Bean;
40-
import org.springframework.test.context.junit4.SpringRunner;
41-
42-
>>>>>>> cdfb77c1 (Remove KubernetesInformers and related infrastructure)
4327
import io.kubernetes.client.informer.SharedIndexInformer;
4428
import io.kubernetes.client.informer.SharedInformerFactory;
4529
import io.kubernetes.client.informer.cache.Lister;
@@ -52,6 +36,15 @@ >>>>>>> cdfb77c1 (Remove KubernetesInformers and related infrastructure)
5236
import io.kubernetes.client.openapi.models.V1PodList;
5337
import io.kubernetes.client.util.ClientBuilder;
5438
import io.kubernetes.client.util.generic.GenericKubernetesApi;
39+
import java.util.Arrays;
40+
import org.junit.Rule;
41+
import org.junit.Test;
42+
import org.junit.runner.RunWith;
43+
import org.springframework.beans.factory.annotation.Autowired;
44+
import org.springframework.boot.autoconfigure.SpringBootApplication;
45+
import org.springframework.boot.test.context.SpringBootTest;
46+
import org.springframework.context.annotation.Bean;
47+
import org.springframework.test.context.junit4.SpringRunner;
5548

5649
@RunWith(SpringRunner.class)
5750
@SpringBootTest
@@ -69,17 +62,21 @@ public ApiClient testingApiClient() {
6962
}
7063

7164
@Bean
72-
public SharedIndexInformer<V1Pod> podInformer(ApiClient apiClient, SharedInformerFactory sharedInformerFactory) {
73-
GenericKubernetesApi<V1Pod, V1PodList> genericApi = new GenericKubernetesApi<>(V1Pod.class, V1PodList.class,
74-
"", "v1", "pods", apiClient);
75-
return sharedInformerFactory.sharedIndexInformerFor( genericApi , V1Pod.class, 0);
65+
public SharedIndexInformer<V1Pod> podInformer(
66+
ApiClient apiClient, SharedInformerFactory sharedInformerFactory) {
67+
GenericKubernetesApi<V1Pod, V1PodList> genericApi =
68+
new GenericKubernetesApi<>(V1Pod.class, V1PodList.class, "", "v1", "pods", apiClient);
69+
return sharedInformerFactory.sharedIndexInformerFor(genericApi, V1Pod.class, 0);
7670
}
7771

7872
@Bean
79-
public SharedIndexInformer<V1ConfigMap> configMapInformer(ApiClient apiClient, SharedInformerFactory sharedInformerFactory) {
80-
GenericKubernetesApi<V1ConfigMap, V1ConfigMapList> genericApi = new GenericKubernetesApi<>(V1ConfigMap.class, V1ConfigMapList.class,
81-
"", "v1", "configmaps", apiClient);
82-
return sharedInformerFactory.sharedIndexInformerFor( genericApi , V1ConfigMap.class, 0, "default");
73+
public SharedIndexInformer<V1ConfigMap> configMapInformer(
74+
ApiClient apiClient, SharedInformerFactory sharedInformerFactory) {
75+
GenericKubernetesApi<V1ConfigMap, V1ConfigMapList> genericApi =
76+
new GenericKubernetesApi<>(
77+
V1ConfigMap.class, V1ConfigMapList.class, "", "v1", "configmaps", apiClient);
78+
return sharedInformerFactory.sharedIndexInformerFor(
79+
genericApi, V1ConfigMap.class, 0, "default");
8380
}
8481
}
8582

0 commit comments

Comments
 (0)