4
4
import java .util .Collections ;
5
5
import java .util .Map ;
6
6
import java .util .Optional ;
7
- import java .util .Set ;
8
7
import java .util .concurrent .TimeUnit ;
9
8
10
9
import io .fabric8 .kubernetes .api .model .HasMetadata ;
11
- import io .fabric8 .kubernetes .client .informers .cache .ItemStore ;
12
10
import io .javaoperatorsdk .operator .api .config .dependent .DependentResourceSpec ;
13
11
import io .javaoperatorsdk .operator .api .config .workflow .WorkflowSpec ;
14
12
import io .javaoperatorsdk .operator .api .reconciler .Reconciler ;
13
+ import io .javaoperatorsdk .operator .processing .dependent .kubernetes .InformerConfigHolder ;
15
14
import io .javaoperatorsdk .operator .processing .event .rate .RateLimiter ;
16
- import io .javaoperatorsdk .operator .processing .event .source .filter .GenericFilter ;
17
- import io .javaoperatorsdk .operator .processing .event .source .filter .OnAddFilter ;
18
- import io .javaoperatorsdk .operator .processing .event .source .filter .OnUpdateFilter ;
19
15
import io .javaoperatorsdk .operator .processing .retry .Retry ;
20
16
21
17
@ SuppressWarnings ("rawtypes" )
@@ -31,7 +27,6 @@ public class ResolvedControllerConfiguration<P extends HasMetadata>
31
27
private final Duration maxReconciliationInterval ;
32
28
private final String finalizer ;
33
29
private final Map <DependentResourceSpec , Object > configurations ;
34
- private final ItemStore <P > itemStore ;
35
30
private final ConfigurationService configurationService ;
36
31
private final String fieldManager ;
37
32
private WorkflowSpec workflowSpec ;
@@ -40,60 +35,35 @@ public ResolvedControllerConfiguration(Class<P> resourceClass, ControllerConfigu
40
35
this (resourceClass , other .getName (), other .isGenerationAware (),
41
36
other .getAssociatedReconcilerClassName (), other .getRetry (), other .getRateLimiter (),
42
37
other .maxReconciliationInterval ().orElse (null ),
43
- other .onAddFilter ().orElse (null ), other .onUpdateFilter ().orElse (null ),
44
- other .genericFilter ().orElse (null ),
45
- other .getNamespaces (),
46
- other .getFinalizerName (), other .getLabelSelector (), Collections .emptyMap (),
47
- other .getItemStore ().orElse (null ), other .fieldManager (),
38
+ other .getFinalizerName (), Collections .emptyMap (),
39
+ other .fieldManager (),
48
40
other .getConfigurationService (),
49
- other .getInformerListLimit ().orElse (null ), other .getWorkflowSpec ().orElse (null ));
50
- }
51
-
52
- public static Duration getMaxReconciliationInterval (long interval , TimeUnit timeUnit ) {
53
- return interval > 0 ? Duration .of (interval , timeUnit .toChronoUnit ()) : null ;
54
- }
55
-
56
- public static String getAssociatedReconcilerClassName (
57
- Class <? extends Reconciler > reconcilerClass ) {
58
- return reconcilerClass .getCanonicalName ();
59
- }
60
-
61
- protected Retry ensureRetry (Retry given ) {
62
- return given == null ? ControllerConfiguration .super .getRetry () : given ;
63
- }
64
-
65
- protected RateLimiter ensureRateLimiter (RateLimiter given ) {
66
- return given == null ? ControllerConfiguration .super .getRateLimiter () : given ;
41
+ other .getInformerConfig (),
42
+ other .getWorkflowSpec ().orElse (null ));
67
43
}
68
44
69
45
public ResolvedControllerConfiguration (Class <P > resourceClass , String name ,
70
46
boolean generationAware , String associatedReconcilerClassName , Retry retry ,
71
47
RateLimiter rateLimiter , Duration maxReconciliationInterval ,
72
- OnAddFilter <? super P > onAddFilter , OnUpdateFilter <? super P > onUpdateFilter ,
73
- GenericFilter <? super P > genericFilter ,
74
- Set <String > namespaces , String finalizer , String labelSelector ,
75
- Map <DependentResourceSpec , Object > configurations , ItemStore <P > itemStore ,
48
+ String finalizer ,
49
+ Map <DependentResourceSpec , Object > configurations ,
76
50
String fieldManager ,
77
- ConfigurationService configurationService , Long informerListLimit ,
51
+ ConfigurationService configurationService ,
52
+ InformerConfigHolder <P > informerConfig ,
78
53
WorkflowSpec workflowSpec ) {
79
54
this (resourceClass , name , generationAware , associatedReconcilerClassName , retry , rateLimiter ,
80
- maxReconciliationInterval , onAddFilter , onUpdateFilter , genericFilter ,
81
- namespaces , finalizer , labelSelector , configurations , itemStore , fieldManager ,
82
- configurationService , informerListLimit );
55
+ maxReconciliationInterval , finalizer , configurations , fieldManager ,
56
+ configurationService , informerConfig );
83
57
setWorkflowSpec (workflowSpec );
84
58
}
85
59
86
60
protected ResolvedControllerConfiguration (Class <P > resourceClass , String name ,
87
61
boolean generationAware , String associatedReconcilerClassName , Retry retry ,
88
- RateLimiter rateLimiter , Duration maxReconciliationInterval ,
89
- OnAddFilter <? super P > onAddFilter , OnUpdateFilter <? super P > onUpdateFilter ,
90
- GenericFilter <? super P > genericFilter ,
91
- Set <String > namespaces , String finalizer , String labelSelector ,
92
- Map <DependentResourceSpec , Object > configurations , ItemStore <P > itemStore ,
62
+ RateLimiter rateLimiter , Duration maxReconciliationInterval , String finalizer ,
63
+ Map <DependentResourceSpec , Object > configurations ,
93
64
String fieldManager ,
94
- ConfigurationService configurationService , Long informerListLimit ) {
95
- super (resourceClass , namespaces , labelSelector , onAddFilter , onUpdateFilter , genericFilter ,
96
- itemStore , informerListLimit );
65
+ ConfigurationService configurationService , InformerConfigHolder <P > informerConfig ) {
66
+ super (resourceClass , informerConfig );
97
67
this .configurationService = configurationService ;
98
68
this .name = ControllerConfiguration .ensureValidName (name , associatedReconcilerClassName );
99
69
this .generationAware = generationAware ;
@@ -102,7 +72,6 @@ protected ResolvedControllerConfiguration(Class<P> resourceClass, String name,
102
72
this .rateLimiter = ensureRateLimiter (rateLimiter );
103
73
this .maxReconciliationInterval = maxReconciliationInterval ;
104
74
this .configurations = configurations != null ? configurations : Collections .emptyMap ();
105
- this .itemStore = itemStore ;
106
75
this .finalizer =
107
76
ControllerConfiguration .ensureValidFinalizerName (finalizer , getResourceTypeName ());
108
77
this .fieldManager = fieldManager ;
@@ -111,8 +80,25 @@ protected ResolvedControllerConfiguration(Class<P> resourceClass, String name,
111
80
protected ResolvedControllerConfiguration (Class <P > resourceClass , String name ,
112
81
Class <? extends Reconciler > reconcilerClas , ConfigurationService configurationService ) {
113
82
this (resourceClass , name , false , getAssociatedReconcilerClassName (reconcilerClas ), null , null ,
114
- null , null , null , null , null ,
115
- null , null , null , null , null , configurationService , null );
83
+ null , null , null , null , configurationService ,
84
+ InformerConfigHolder .builder (resourceClass ).buildForController ());
85
+ }
86
+
87
+ public static Duration getMaxReconciliationInterval (long interval , TimeUnit timeUnit ) {
88
+ return interval > 0 ? Duration .of (interval , timeUnit .toChronoUnit ()) : null ;
89
+ }
90
+
91
+ public static String getAssociatedReconcilerClassName (
92
+ Class <? extends Reconciler > reconcilerClass ) {
93
+ return reconcilerClass .getCanonicalName ();
94
+ }
95
+
96
+ protected Retry ensureRetry (Retry given ) {
97
+ return given == null ? ControllerConfiguration .super .getRetry () : given ;
98
+ }
99
+
100
+ protected RateLimiter ensureRateLimiter (RateLimiter given ) {
101
+ return given == null ? ControllerConfiguration .super .getRateLimiter () : given ;
116
102
}
117
103
118
104
@ Override
@@ -177,11 +163,6 @@ public <C> C getConfigurationFor(DependentResourceSpec<?, P, C> spec) {
177
163
return (C ) config ;
178
164
}
179
165
180
- @ Override
181
- public Optional <ItemStore <P >> getItemStore () {
182
- return Optional .ofNullable (itemStore );
183
- }
184
-
185
166
@ Override
186
167
public String fieldManager () {
187
168
return fieldManager ;
0 commit comments