55import io .fabric8 .kubernetes .client .dsl .MixedOperation ;
66import io .javaoperatorsdk .operator .api .ResourceController ;
77import io .javaoperatorsdk .operator .api .config .ConfigurationService ;
8+ import io .javaoperatorsdk .operator .api .config .ControllerConfiguration ;
89import io .javaoperatorsdk .operator .processing .CustomResourceCache ;
910import io .javaoperatorsdk .operator .processing .DefaultEventHandler ;
1011import io .javaoperatorsdk .operator .processing .EventDispatcher ;
@@ -30,31 +31,30 @@ public Operator(KubernetesClient k8sClient, ConfigurationService configurationSe
3031
3132 public <R extends CustomResource > void register (ResourceController <R > controller )
3233 throws OperatorException {
33- final var configuration = configurationService .getConfigurationFor (controller );
34- if (configuration == null ) {
34+ register (controller , null );
35+ }
36+
37+ public <R extends CustomResource > void register (
38+ ResourceController <R > controller , ControllerConfiguration <R > configuration )
39+ throws OperatorException {
40+ final var existing = configurationService .getConfigurationFor (controller );
41+ if (existing == null ) {
3542 log .warn (
3643 "Skipping registration of {} controller named {} because its configuration cannot be found.\n "
3744 + "Known controllers are: {}" ,
3845 controller .getClass ().getCanonicalName (),
3946 ControllerUtils .getNameFor (controller ),
4047 configurationService .getKnownControllerNames ());
4148 } else {
49+ if (configuration == null ) {
50+ configuration = existing ;
51+ }
4252 final var retry = GenericRetry .fromConfiguration (configuration .getRetryConfiguration ());
4353 final var targetNamespaces = configuration .getNamespaces ().toArray (new String [] {});
4454 registerController (controller , configuration .watchAllNamespaces (), retry , targetNamespaces );
4555 }
4656 }
4757
48- // currently only used by IntegrationTestSupport but this should also disappear as by default the
49- // controllers should register into the current namespace the client is connected to which should
50- // work as expected for tests, in particular if we want to start testing using random namespace
51- // names
52- <R extends CustomResource > void registerController (
53- ResourceController <R > controller , Retry retry , String ... targetNamespaces )
54- throws OperatorException {
55- registerController (controller , false , retry , targetNamespaces );
56- }
57-
5858 @ SuppressWarnings ("rawtypes" )
5959 private <R extends CustomResource > void registerController (
6060 ResourceController <R > controller ,
0 commit comments