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>
1515 private final Set <String > namespaces ;
1616 private final boolean watchAllNamespaces ;
1717 private final RetryConfiguration retryConfiguration ;
18+ private ConfigurationService service ;
1819
1920 public AbstractControllerConfiguration (
2021 String associatedControllerClassName ,
@@ -77,4 +78,14 @@ public boolean watchAllNamespaces() {
7778 public RetryConfiguration getRetryConfiguration () {
7879 return retryConfiguration ;
7980 }
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+ }
8091}
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ default Set<String> getNamespaces() {
2626 default boolean watchAllNamespaces () {
2727 return allNamespacesWatched (getNamespaces ());
2828 }
29-
29+
3030 static boolean allNamespacesWatched (Set <String > namespaces ) {
3131 return namespaces == null || namespaces .isEmpty ();
3232 }
@@ -36,10 +36,16 @@ default boolean watchCurrentNamespace() {
3636 }
3737
3838 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 );
4042 }
4143
4244 default RetryConfiguration getRetryConfiguration () {
4345 return RetryConfiguration .DEFAULT ;
4446 }
47+
48+ ConfigurationService getConfigurationService ();
49+
50+ void setConfigurationService (ConfigurationService service );
4551}
Original file line number Diff line number Diff line change 99import io .fabric8 .kubernetes .client .WatcherException ;
1010import io .fabric8 .kubernetes .client .dsl .MixedOperation ;
1111import io .fabric8 .kubernetes .client .dsl .internal .CustomResourceOperationsImpl ;
12+ import io .javaoperatorsdk .operator .api .config .ControllerConfiguration ;
1213import io .javaoperatorsdk .operator .processing .CustomResourceCache ;
1314import io .javaoperatorsdk .operator .processing .KubernetesResourceUtils ;
1415import io .javaoperatorsdk .operator .processing .event .AbstractEventSource ;
1516import java .util .ArrayList ;
1617import java .util .List ;
1718import java .util .Map ;
19+ import java .util .Set ;
1820import java .util .concurrent .ConcurrentHashMap ;
1921import org .slf4j .Logger ;
2022import org .slf4j .LoggerFactory ;
@@ -71,14 +73,10 @@ private CustomResourceEventSource(
7173 this .resClass = resClass .getName ();
7274 }
7375
74- private boolean isWatchAllNamespaces () {
75- return targetNamespaces == null ;
76- }
77-
7876 @ Override
7977 public void start () {
8078 CustomResourceOperationsImpl crClient = (CustomResourceOperationsImpl ) client ;
81- if (isWatchAllNamespaces ( )) {
79+ if (ControllerConfiguration . allNamespacesWatched ( Set . of ( targetNamespaces ) )) {
8280 var w = crClient .inAnyNamespace ().watch (this );
8381 watches .add (w );
8482 log .debug ("Registered controller {} -> {} for any namespace" , resClass , w );
Original file line number Diff line number Diff line change 44import io .javaoperatorsdk .operator .ControllerUtils ;
55import io .javaoperatorsdk .operator .api .Controller ;
66import io .javaoperatorsdk .operator .api .ResourceController ;
7+ import io .javaoperatorsdk .operator .api .config .ConfigurationService ;
78import io .javaoperatorsdk .operator .api .config .ControllerConfiguration ;
89import java .util .Optional ;
910import java .util .Set ;
@@ -14,6 +15,7 @@ public class AnnotationConfiguration<R extends CustomResource>
1415
1516 private final ResourceController <R > controller ;
1617 private final Optional <Controller > annotation ;
18+ private ConfigurationService service ;
1719
1820 public AnnotationConfiguration (ResourceController <R > controller ) {
1921 this .controller = controller ;
@@ -53,6 +55,16 @@ public Set<String> getNamespaces() {
5355 return Set .of (annotation .map (Controller ::namespaces ).orElse (new String [] {}));
5456 }
5557
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+
5668 @ Override
5769 public String getAssociatedControllerClassName () {
5870 return controller .getClass ().getCanonicalName ();
You can’t perform that action at this time.
0 commit comments