Skip to content

Commit 7f69d7f

Browse files
authored
Merge pull request #1686 from dsyer/shared-informer
Fix SpringExampleController so it doesn't crash on startup
2 parents 366aa1e + b61f2e9 commit 7f69d7f

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,6 @@ public KubernetesControllerFactory kubernetesReconcilerConfigurer(
7373
SharedInformerFactory sharedInformerFactory, Reconciler reconciler) {
7474
return new KubernetesControllerFactory(sharedInformerFactory, reconciler);
7575
}
76-
77-
// *REQUIRED*
78-
// Injecting your SharedInformerFactory class annotated `@KubernetesInformers`
79-
@Bean("sharedInformerFactory")
80-
public SharedInformerFactory sharedInformerFactory() {
81-
return new MySharedInformerFactory();
82-
}
8376
}
8477

8578
@KubernetesInformers({ // Defining what resources is the informer-factory actually watching.
@@ -100,6 +93,7 @@ public SharedInformerFactory sharedInformerFactory() {
10093
groupVersionResource =
10194
@GroupVersionResource(apiGroup = "", apiVersion = "v1", resourcePlural = "pods")),
10295
})
96+
@Component
10397
public static class MySharedInformerFactory extends SharedInformerFactory {}
10498

10599
// As long as a reconciler bean attached `@KubernetesReconciler` detected in the context, we

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,6 @@ public KubernetesControllerFactory kubernetesReconcilerConfigurer(
7373
SharedInformerFactory sharedInformerFactory, Reconciler reconciler) {
7474
return new KubernetesControllerFactory(sharedInformerFactory, reconciler);
7575
}
76-
77-
// *REQUIRED*
78-
// Injecting your SharedInformerFactory class annotated `@KubernetesInformers`
79-
@Bean("sharedInformerFactory")
80-
public SharedInformerFactory sharedInformerFactory() {
81-
return new MySharedInformerFactory();
82-
}
8376
}
8477

8578
@KubernetesInformers({ // Defining what resources is the informer-factory actually watching.
@@ -100,6 +93,7 @@ public SharedInformerFactory sharedInformerFactory() {
10093
groupVersionResource =
10194
@GroupVersionResource(apiGroup = "", apiVersion = "v1", resourcePlural = "pods")),
10295
})
96+
@Component
10397
public static class MySharedInformerFactory extends SharedInformerFactory {}
10498

10599
// As long as a reconciler bean attached `@KubernetesReconciler` detected in the context, we

0 commit comments

Comments
 (0)