Skip to content

Commit 3bf4ab2

Browse files
committed
feat: externalize watching all/current namespace(s) decision logic
1 parent 112a826 commit 3bf4ab2

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ControllerConfiguration.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,19 @@ default Set<String> getNamespaces() {
2424
}
2525

2626
default boolean watchAllNamespaces() {
27-
return getNamespaces().isEmpty();
27+
return allNamespacesWatched(getNamespaces());
28+
}
29+
30+
static boolean allNamespacesWatched(Set<String> namespaces) {
31+
return namespaces == null || namespaces.isEmpty();
2832
}
2933

3034
default boolean watchCurrentNamespace() {
31-
final var namespaces = getNamespaces();
32-
return namespaces.size() == 1 && namespaces.contains(Controller.WATCH_CURRENT_NAMESPACE);
35+
return currentNamespaceWatched(getNamespaces());
36+
}
37+
38+
static boolean currentNamespaceWatched(Set<String> namespaces) {
39+
return namespaces != null && namespaces.size() == 1 && namespaces.contains(Controller.WATCH_CURRENT_NAMESPACE);
3340
}
3441

3542
default RetryConfiguration getRetryConfiguration() {

0 commit comments

Comments
 (0)