1
1
package io .javaoperatorsdk .operator .api .config ;
2
2
3
- import java .util .Collections ;
4
3
import java .util .Set ;
5
4
6
5
import io .fabric8 .kubernetes .api .model .HasMetadata ;
7
6
import io .javaoperatorsdk .operator .processing .event .source .ResourceEventFilter ;
8
7
9
8
public class DefaultControllerConfiguration <R extends HasMetadata >
9
+ extends DefaultResourceConfiguration <R , ControllerConfiguration <R >>
10
10
implements ControllerConfiguration <R > {
11
11
12
12
private final String associatedControllerClassName ;
13
13
private final String name ;
14
- private final String crdName ;
15
14
private final String finalizer ;
16
- private final boolean generationAware ;
17
- private final Set <String > namespaces ;
18
- private final boolean watchAllNamespaces ;
19
15
private final RetryConfiguration retryConfiguration ;
20
- private final String labelSelector ;
21
16
private final ResourceEventFilter <R , ControllerConfiguration <R >> resourceEventFilter ;
22
- private final Class <R > resourceClass ;
23
- private ConfigurationService service ;
17
+ private final boolean generationAware ;
24
18
25
19
public DefaultControllerConfiguration (
26
20
String associatedControllerClassName ,
27
21
String name ,
28
- String crdName ,
22
+ String resourceName ,
29
23
String finalizer ,
30
24
boolean generationAware ,
31
25
Set <String > namespaces ,
@@ -34,92 +28,50 @@ public DefaultControllerConfiguration(
34
28
ResourceEventFilter <R , ControllerConfiguration <R >> resourceEventFilter ,
35
29
Class <R > resourceClass ,
36
30
ConfigurationService service ) {
31
+ super (resourceName , resourceClass , namespaces , labelSelector , service );
37
32
this .associatedControllerClassName = associatedControllerClassName ;
38
33
this .name = name ;
39
- this .crdName = crdName ;
40
34
this .finalizer = finalizer ;
41
35
this .generationAware = generationAware ;
42
- this .namespaces =
43
- namespaces != null ? Collections .unmodifiableSet (namespaces ) : Collections .emptySet ();
44
- this .watchAllNamespaces = this .namespaces .isEmpty ();
45
36
this .retryConfiguration =
46
37
retryConfiguration == null
47
38
? ControllerConfiguration .super .getRetryConfiguration ()
48
39
: retryConfiguration ;
49
- this .labelSelector = labelSelector ;
50
40
this .resourceEventFilter = resourceEventFilter ;
51
- this .resourceClass =
52
- resourceClass == null ? ControllerConfiguration .super .getResourceClass ()
53
- : resourceClass ;
54
- setConfigurationService (service );
55
41
}
56
42
57
43
@ Override
58
44
public String getName () {
59
45
return name ;
60
46
}
61
47
62
- @ Override
63
- public String getResourceTypeName () {
64
- return crdName ;
65
- }
66
-
67
48
@ Override
68
49
public String getFinalizer () {
69
50
return finalizer ;
70
51
}
71
52
72
- @ Override
73
- public boolean isGenerationAware () {
74
- return generationAware ;
75
- }
76
-
77
53
@ Override
78
54
public String getAssociatedReconcilerClassName () {
79
55
return associatedControllerClassName ;
80
56
}
81
57
82
- @ Override
83
- public Set <String > getNamespaces () {
84
- return namespaces ;
85
- }
86
-
87
- @ Override
88
- public boolean watchAllNamespaces () {
89
- return watchAllNamespaces ;
90
- }
91
-
92
58
@ Override
93
59
public RetryConfiguration getRetryConfiguration () {
94
60
return retryConfiguration ;
95
61
}
96
62
97
63
@ Override
98
- public ConfigurationService getConfigurationService () {
99
- return service ;
100
- }
101
-
102
- @ Override
103
- public void setConfigurationService (ConfigurationService service ) {
104
- if (this .service != null ) {
105
- throw new RuntimeException ("A ConfigurationService is already associated with '" + name
106
- + "' ControllerConfiguration. Cannot change it once set!" );
107
- }
108
- this .service = service ;
109
- }
110
-
111
- @ Override
112
- public String getLabelSelector () {
113
- return labelSelector ;
64
+ public boolean isGenerationAware () {
65
+ return generationAware ;
114
66
}
115
67
116
68
@ Override
117
- public Class < R > getResourceClass () {
118
- return resourceClass ;
69
+ public ResourceEventFilter < R , ControllerConfiguration < R >> getEventFilter () {
70
+ return resourceEventFilter ;
119
71
}
120
72
121
73
@ Override
122
- public ResourceEventFilter < R , ControllerConfiguration < R >> getEventFilter () {
123
- return resourceEventFilter ;
74
+ protected String identifierForException () {
75
+ return "'" + name + "' ControllerConfiguration" ;
124
76
}
125
77
}
0 commit comments