@@ -70,7 +70,7 @@ public void start() {
7070
7171 log .info ("Client version: {}" , Version .clientVersion ());
7272 try {
73- final var k8sVersion = kubernetesClient .getVersion ();
73+ final var k8sVersion = kubernetesClient .getKubernetesVersion ();
7474 if (k8sVersion != null ) {
7575 log .info ("Server version: {}.{}" , k8sVersion .getMajor (), k8sVersion .getMinor ());
7676 }
@@ -110,13 +110,14 @@ public void close() {
110110 * Add a registration requests for the specified controller with this operator. The effective
111111 * registration of the controller is delayed till the operator is started.
112112 *
113- * @param controller the controller to register
113+ * @param reconciler the controller to register
114114 * @param <R> the {@code CustomResource} type associated with the controller
115115 * @throws OperatorException if a problem occurred during the registration process
116116 */
117- public <R extends HasMetadata > void register (Reconciler <R > controller )
117+ public <R extends HasMetadata > void register (Reconciler <R > reconciler )
118118 throws OperatorException {
119- register (controller , null );
119+ final var defaultConfiguration = configurationService .getConfigurationFor (reconciler );
120+ register (reconciler , defaultConfiguration );
120121 }
121122
122123 /**
@@ -127,39 +128,34 @@ public <R extends HasMetadata> void register(Reconciler<R> controller)
127128 * controller is delayed till the operator is started.
128129 *
129130 * @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
132132 * @param <R> the {@code CustomResource} type associated with the controller
133133 * @throws OperatorException if a problem occurred during the registration process
134134 */
135- public <R extends HasMetadata > void register (
136- Reconciler < R > reconciler , ControllerConfiguration <R > configuration )
135+ public <R extends HasMetadata > void register (Reconciler < R > reconciler ,
136+ ControllerConfiguration <R > configuration )
137137 throws OperatorException {
138- final var existing = configurationService . getConfigurationFor ( reconciler );
139- if (existing == null ) {
138+
139+ if (configuration == null ) {
140140 throw new OperatorException (
141141 "Cannot register controller with name " + reconciler .getClass ().getCanonicalName () +
142142 " controller named " + ControllerUtils .getNameFor (reconciler )
143143 + " because its configuration cannot be found.\n " +
144144 " 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 .getResourceClass (),
161- watchedNS );
162145 }
146+
147+ final var controller = new Controller <>(reconciler , configuration , kubernetesClient );
148+
149+ controllers .add (controller );
150+
151+ final var watchedNS = configuration .watchAllNamespaces () ? "[all namespaces]"
152+ : configuration .getEffectiveNamespaces ();
153+
154+ log .info (
155+ "Registered Controller: '{}' for CRD: '{}' for namespace(s): {}" ,
156+ configuration .getName (),
157+ configuration .getResourceClass (),
158+ watchedNS );
163159 }
164160
165161 static class ControllerManager implements LifecycleAware {
0 commit comments