@@ -110,13 +110,14 @@ public void close() {
110
110
* Add a registration requests for the specified controller with this operator. The effective
111
111
* registration of the controller is delayed till the operator is started.
112
112
*
113
- * @param controller the controller to register
113
+ * @param reconciler the controller to register
114
114
* @param <R> the {@code CustomResource} type associated with the controller
115
115
* @throws OperatorException if a problem occurred during the registration process
116
116
*/
117
- public <R extends CustomResource <?, ?>> void register (Reconciler <R > controller )
117
+ public <R extends CustomResource <?, ?>> void register (Reconciler <R > reconciler )
118
118
throws OperatorException {
119
- register (controller , null );
119
+ final var defaultConfiguration = configurationService .getConfigurationFor (reconciler );
120
+ register (reconciler , defaultConfiguration );
120
121
}
121
122
122
123
/**
@@ -127,39 +128,34 @@ public void close() {
127
128
* controller is delayed till the operator is started.
128
129
*
129
130
* @param reconciler part of the controller to register
130
- * @param configuration the configuration with which we want to register the controller, if {@code
131
- * null}, the controller's original configuration is used
131
+ * @param configuration the configuration with which we want to register the controller
132
132
* @param <R> the {@code CustomResource} type associated with the controller
133
133
* @throws OperatorException if a problem occurred during the registration process
134
134
*/
135
- public <R extends CustomResource <?, ?>> void register (
136
- Reconciler < R > reconciler , ControllerConfiguration <R > configuration )
135
+ public <R extends CustomResource <?, ?>> void register (Reconciler < R > reconciler ,
136
+ ControllerConfiguration <R > configuration )
137
137
throws OperatorException {
138
- final var existing = configurationService . getConfigurationFor ( reconciler );
139
- if (existing == null ) {
138
+
139
+ if (configuration == null ) {
140
140
throw new OperatorException (
141
141
"Cannot register controller with name " + reconciler .getClass ().getCanonicalName () +
142
142
" controller named " + ControllerUtils .getNameFor (reconciler )
143
143
+ " because its configuration cannot be found.\n " +
144
144
" Known controllers are: " + configurationService .getKnownControllerNames ());
145
- } else {
146
- if (configuration == null ) {
147
- configuration = existing ;
148
- }
149
- final var controller =
150
- new Controller <>(reconciler , configuration , kubernetesClient );
151
- controllers .add (controller );
152
-
153
- final var watchedNS =
154
- configuration .watchAllNamespaces ()
155
- ? "[all namespaces]"
156
- : configuration .getEffectiveNamespaces ();
157
- log .info (
158
- "Registered Controller: '{}' for CRD: '{}' for namespace(s): {}" ,
159
- configuration .getName (),
160
- configuration .getCustomResourceClass (),
161
- watchedNS );
162
145
}
146
+
147
+ final var controller = new Controller <>(reconciler , configuration , kubernetesClient );
148
+
149
+ controllers .add (controller );
150
+
151
+ final var watchedNS =
152
+ configuration .watchAllNamespaces () ? "[all namespaces]" : configuration .getEffectiveNamespaces ();
153
+
154
+ log .info (
155
+ "Registered Controller: '{}' for CRD: '{}' for namespace(s): {}" ,
156
+ configuration .getName (),
157
+ configuration .getCustomResourceClass (),
158
+ watchedNS );
163
159
}
164
160
165
161
static class ControllerManager implements LifecycleAware {
0 commit comments