Skip to content

Commit a8549dd

Browse files
committed
feat: added additional cache methods
1 parent 86f77fe commit a8549dd

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/internal/ControllerResourceEventSource.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,24 @@ public Stream<T> getCachedCustomResources(Predicate<T> predicate) {
196196
return resStream;
197197
}
198198

199+
/**
200+
* Use only if the operator is watching specific namespace(s).
201+
* @param namespace - namespace to filter on
202+
* @return stream of cached resources from the specified namespace
203+
*/
204+
public Stream<T> getCachedCustomResources(String namespace) {
205+
return sharedIndexInformers.get(namespace).getStore().list().stream();
206+
}
207+
208+
/**
209+
* Use only if the operator is watching specific namespace(s).
210+
* @param namespace - namespace to filter on
211+
* @return stream of cached resources from the specified namespace
212+
*/
213+
public Stream<T> getCachedCustomResources(String namespace, Predicate<T> predicate) {
214+
return sharedIndexInformers.get(namespace).getStore().list().stream().filter(predicate);
215+
}
216+
199217
/**
200218
* @return shared informers by namespace. If custom resource is not namespace scoped use
201219
* CustomResourceEventSource.ANY_NAMESPACE_MAP_KEY

0 commit comments

Comments
 (0)