File tree Expand file tree Collapse file tree 4 files changed +34
-7
lines changed
operator-framework-core/src/main/java/io/javaoperatorsdk/operator
processing/event/internal
operator-framework/src/main/java/io/javaoperatorsdk/operator/config/runtime Expand file tree Collapse file tree 4 files changed +34
-7
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ public abstract class AbstractControllerConfiguration<R extends CustomResource>
15
15
private final Set <String > namespaces ;
16
16
private final boolean watchAllNamespaces ;
17
17
private final RetryConfiguration retryConfiguration ;
18
+ private ConfigurationService service ;
18
19
19
20
public AbstractControllerConfiguration (
20
21
String associatedControllerClassName ,
@@ -77,4 +78,14 @@ public boolean watchAllNamespaces() {
77
78
public RetryConfiguration getRetryConfiguration () {
78
79
return retryConfiguration ;
79
80
}
81
+
82
+ @ Override
83
+ public ConfigurationService getConfigurationService () {
84
+ return service ;
85
+ }
86
+
87
+ @ Override
88
+ public void setConfigurationService (ConfigurationService service ) {
89
+ this .service = service ;
90
+ }
80
91
}
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ default Set<String> getNamespaces() {
26
26
default boolean watchAllNamespaces () {
27
27
return allNamespacesWatched (getNamespaces ());
28
28
}
29
-
29
+
30
30
static boolean allNamespacesWatched (Set <String > namespaces ) {
31
31
return namespaces == null || namespaces .isEmpty ();
32
32
}
@@ -36,10 +36,16 @@ default boolean watchCurrentNamespace() {
36
36
}
37
37
38
38
static boolean currentNamespaceWatched (Set <String > namespaces ) {
39
- return namespaces != null && namespaces .size () == 1 && namespaces .contains (Controller .WATCH_CURRENT_NAMESPACE );
39
+ return namespaces != null
40
+ && namespaces .size () == 1
41
+ && namespaces .contains (Controller .WATCH_CURRENT_NAMESPACE );
40
42
}
41
43
42
44
default RetryConfiguration getRetryConfiguration () {
43
45
return RetryConfiguration .DEFAULT ;
44
46
}
47
+
48
+ ConfigurationService getConfigurationService ();
49
+
50
+ void setConfigurationService (ConfigurationService service );
45
51
}
Original file line number Diff line number Diff line change 9
9
import io .fabric8 .kubernetes .client .WatcherException ;
10
10
import io .fabric8 .kubernetes .client .dsl .MixedOperation ;
11
11
import io .fabric8 .kubernetes .client .dsl .internal .CustomResourceOperationsImpl ;
12
+ import io .javaoperatorsdk .operator .api .config .ControllerConfiguration ;
12
13
import io .javaoperatorsdk .operator .processing .CustomResourceCache ;
13
14
import io .javaoperatorsdk .operator .processing .KubernetesResourceUtils ;
14
15
import io .javaoperatorsdk .operator .processing .event .AbstractEventSource ;
15
16
import java .util .ArrayList ;
16
17
import java .util .List ;
17
18
import java .util .Map ;
19
+ import java .util .Set ;
18
20
import java .util .concurrent .ConcurrentHashMap ;
19
21
import org .slf4j .Logger ;
20
22
import org .slf4j .LoggerFactory ;
@@ -71,14 +73,10 @@ private CustomResourceEventSource(
71
73
this .resClass = resClass .getName ();
72
74
}
73
75
74
- private boolean isWatchAllNamespaces () {
75
- return targetNamespaces == null ;
76
- }
77
-
78
76
@ Override
79
77
public void start () {
80
78
CustomResourceOperationsImpl crClient = (CustomResourceOperationsImpl ) client ;
81
- if (isWatchAllNamespaces ( )) {
79
+ if (ControllerConfiguration . allNamespacesWatched ( Set . of ( targetNamespaces ) )) {
82
80
var w = crClient .inAnyNamespace ().watch (this );
83
81
watches .add (w );
84
82
log .debug ("Registered controller {} -> {} for any namespace" , resClass , w );
Original file line number Diff line number Diff line change 4
4
import io .javaoperatorsdk .operator .ControllerUtils ;
5
5
import io .javaoperatorsdk .operator .api .Controller ;
6
6
import io .javaoperatorsdk .operator .api .ResourceController ;
7
+ import io .javaoperatorsdk .operator .api .config .ConfigurationService ;
7
8
import io .javaoperatorsdk .operator .api .config .ControllerConfiguration ;
8
9
import java .util .Optional ;
9
10
import java .util .Set ;
@@ -14,6 +15,7 @@ public class AnnotationConfiguration<R extends CustomResource>
14
15
15
16
private final ResourceController <R > controller ;
16
17
private final Optional <Controller > annotation ;
18
+ private ConfigurationService service ;
17
19
18
20
public AnnotationConfiguration (ResourceController <R > controller ) {
19
21
this .controller = controller ;
@@ -53,6 +55,16 @@ public Set<String> getNamespaces() {
53
55
return Set .of (annotation .map (Controller ::namespaces ).orElse (new String [] {}));
54
56
}
55
57
58
+ @ Override
59
+ public ConfigurationService getConfigurationService () {
60
+ return service ;
61
+ }
62
+
63
+ @ Override
64
+ public void setConfigurationService (ConfigurationService service ) {
65
+ this .service = service ;
66
+ }
67
+
56
68
@ Override
57
69
public String getAssociatedControllerClassName () {
58
70
return controller .getClass ().getCanonicalName ();
You can’t perform that action at this time.
0 commit comments