5
5
import io .fabric8 .kubernetes .client .dsl .MixedOperation ;
6
6
import io .javaoperatorsdk .operator .api .ResourceController ;
7
7
import io .javaoperatorsdk .operator .api .config .ConfigurationService ;
8
+ import io .javaoperatorsdk .operator .api .config .ControllerConfiguration ;
8
9
import io .javaoperatorsdk .operator .processing .CustomResourceCache ;
9
10
import io .javaoperatorsdk .operator .processing .DefaultEventHandler ;
10
11
import io .javaoperatorsdk .operator .processing .EventDispatcher ;
@@ -30,31 +31,30 @@ public Operator(KubernetesClient k8sClient, ConfigurationService configurationSe
30
31
31
32
public <R extends CustomResource > void register (ResourceController <R > controller )
32
33
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 ) {
35
42
log .warn (
36
43
"Skipping registration of {} controller named {} because its configuration cannot be found.\n "
37
44
+ "Known controllers are: {}" ,
38
45
controller .getClass ().getCanonicalName (),
39
46
ControllerUtils .getNameFor (controller ),
40
47
configurationService .getKnownControllerNames ());
41
48
} else {
49
+ if (configuration == null ) {
50
+ configuration = existing ;
51
+ }
42
52
final var retry = GenericRetry .fromConfiguration (configuration .getRetryConfiguration ());
43
53
final var targetNamespaces = configuration .getNamespaces ().toArray (new String [] {});
44
54
registerController (controller , configuration .watchAllNamespaces (), retry , targetNamespaces );
45
55
}
46
56
}
47
57
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
-
58
58
@ SuppressWarnings ("rawtypes" )
59
59
private <R extends CustomResource > void registerController (
60
60
ResourceController <R > controller ,
0 commit comments