Skip to content

Commit aa978c2

Browse files
committed
wip
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent f70459c commit aa978c2

4 files changed

Lines changed: 19 additions & 25 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ default boolean followControllerNamespaceChanges() {
7676

7777
<P extends HasMetadata> PrimaryToSecondaryMapper<P> getPrimaryToSecondaryMapper();
7878

79+
// todo deprecate
7980
Optional<GroupVersionKind> getGroupVersionKind();
8081

8182
default String name() {

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/InformerEventSource.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ public class InformerEventSource<R extends HasMetadata, P extends HasMetadata>
5252
private final PrimaryToSecondaryIndex<R> primaryToSecondaryIndex;
5353
private final PrimaryToSecondaryMapper<P> primaryToSecondaryMapper;
5454

55+
/**
56+
* @deprecated use {@link InformerEventSource(InformerEventSourceConfiguration)}
57+
*/
58+
// todo migrate sample, separate PR?
59+
@Deprecated(forRemoval = true)
5560
public InformerEventSource(
5661
InformerEventSourceConfiguration<R> configuration, EventSourceContext<P> context) {
5762
this(configuration);

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/InformerManager.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,21 +104,22 @@ private void initSources() {
104104

105105
public void changeNamespaces(Set<String> namespaces) {
106106
var sourcesToRemove =
107-
sources.keySet().stream().filter(k -> !namespaces.contains(k)).collect(Collectors.toSet());
107+
sources.entrySet().stream()
108+
.filter(e -> !namespaces.contains(e.getKey()))
109+
.collect(Collectors.toSet());
108110
log.debug("Stopped informer {} for namespaces: {}", this, sourcesToRemove);
109111
sourcesToRemove.forEach(
110-
k -> {
112+
e -> {
111113
var informer =
112114
informerPool.releaseInformer(
113115
controllerConfiguration.getName(),
114116
configuration.getInformerConfig().getName(),
115-
getClassifier(k));
116-
sources.remove(k);
117+
e.getValue().getClassifier());
118+
sources.remove(e.getKey());
117119
informer.ifPresent(i -> i.removeEventHandler(eventHandler));
118120
});
119121

120-
var newNamespaces =
121-
namespaces.stream().filter(ns -> !sources.containsKey(ns)).collect(Collectors.toList());
122+
var newNamespaces = namespaces.stream().filter(ns -> !sources.containsKey(ns)).toList();
122123
if (newNamespaces.isEmpty()) {
123124
return;
124125
}

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/pool/AbstractInformerPool.java

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,27 +67,14 @@ protected SharedIndexInformer createInformer(
6767

6868
FilterWatchListDeletable filteredClient;
6969
if (WATCH_ALL_NAMESPACES.equals(classifier.namespaceIdentifier())) {
70-
filteredClient =
71-
clientWithResource
72-
.inAnyNamespace()
73-
.withLabelSelector(classifier.labelSelector())
74-
.withShardSelector(classifier.shardSelector());
70+
filteredClient = clientWithResource.inAnyNamespace();
7571
} else {
76-
filteredClient =
77-
clientWithResource
78-
.inNamespace(classifier.namespaceIdentifier())
79-
.withLabelSelector(classifier.labelSelector())
80-
.withShardSelector(classifier.shardSelector());
81-
}
82-
83-
if (classifier.labelSelector() != null) {
84-
filteredClient =
85-
(FilterWatchListDeletable) filteredClient.withLabelSelector(classifier.labelSelector());
86-
}
87-
if (classifier.shardSelector() != null) {
88-
filteredClient =
89-
(FilterWatchListDeletable) filteredClient.withShardSelector(classifier.shardSelector());
72+
filteredClient = clientWithResource.inNamespace(classifier.namespaceIdentifier());
9073
}
74+
filteredClient =
75+
(FilterWatchListDeletable) filteredClient.withLabelSelector(classifier.labelSelector());
76+
filteredClient =
77+
(FilterWatchListDeletable) filteredClient.withShardSelector(classifier.shardSelector());
9178

9279
if (classifier.fieldSelector() != null && !classifier.fieldSelector().getFields().isEmpty()) {
9380
for (var f : classifier.fieldSelector().getFields()) {

0 commit comments

Comments
 (0)