Skip to content

Commit 1b8aae5

Browse files
committed
fix: properly set default namespaces in controller case
Signed-off-by: Chris Laprun <[email protected]>
1 parent 421460b commit 1b8aae5

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

Diff for: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/InformerConfig.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,22 @@
2525

2626
/**
2727
* Specified which namespaces the associated informer monitors for custom resources events. If no
28-
* namespace is specified then the informer will monitor the namespaces configured for the
29-
* associated controller (or all namespaces if the configuration is done for a controller).
28+
* namespace is specified then which namespaces the informer will monitor will depend on the
29+
* context in which the informer is configured:
30+
* <ul>
31+
* <li>all namespaces if configuring a controller informer</li>
32+
* <li>the namespaces configured for the associated controller if configuring an event source</li>
33+
* </ul>
3034
*
35+
* You can set a list of namespaces or use the following constants:
3136
* <ul>
32-
* You can set a list of namespaces or also constants:
3337
* <li>{@link Constants#WATCH_ALL_NAMESPACES}</li>
3438
* <li>{@link Constants#WATCH_CURRENT_NAMESPACE}</li>
3539
* <li>{@link Constants#SAME_AS_CONTROLLER}</li>
3640
* </ul>
3741
*
3842
* @return the array of namespaces the associated informer monitors
3943
*/
40-
// todo: use unset value as semantics needs to be different depending on whether the configuration
41-
// is used on a controller or an informer
4244
String[] namespaces() default {Constants.SAME_AS_CONTROLLER};
4345

4446
/**

Diff for: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/InformerConfigHolder.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ void updateInformerConfigBuilder(
125125
public class Builder {
126126

127127
public InformerConfigHolder<R> buildForController() {
128-
if (namespaces == null || namespaces.isEmpty()) {
128+
// if the informer config uses the default "same as controller" value, reset the namespaces to
129+
// the default set for controllers
130+
if (namespaces == null || namespaces.isEmpty()
131+
|| InformerConfiguration.inheritsNamespacesFromController(namespaces)) {
129132
namespaces = Constants.DEFAULT_NAMESPACES_SET;
130133
}
131134
return InformerConfigHolder.this;

0 commit comments

Comments
 (0)