|
6 | 6 | import java.util.Optional;
|
7 | 7 | import java.util.concurrent.ConcurrentHashMap;
|
8 | 8 | import java.util.function.Predicate;
|
9 |
| -import java.util.stream.Collectors; |
10 | 9 | import java.util.stream.Stream;
|
11 | 10 |
|
12 |
| -import org.slf4j.Logger; |
13 |
| -import org.slf4j.LoggerFactory; |
14 |
| - |
15 | 11 | import io.fabric8.kubernetes.api.model.HasMetadata;
|
16 | 12 | import io.fabric8.kubernetes.api.model.KubernetesResourceList;
|
17 | 13 | import io.fabric8.kubernetes.client.KubernetesClientException;
|
|
27 | 23 | import io.javaoperatorsdk.operator.processing.ResourceCache;
|
28 | 24 | import io.javaoperatorsdk.operator.processing.event.ResourceID;
|
29 | 25 |
|
| 26 | +import org.slf4j.Logger; |
| 27 | +import org.slf4j.LoggerFactory; |
| 28 | + |
30 | 29 | import static io.javaoperatorsdk.operator.processing.KubernetesResourceUtils.getName;
|
31 | 30 | import static io.javaoperatorsdk.operator.processing.KubernetesResourceUtils.getUID;
|
32 | 31 | import static io.javaoperatorsdk.operator.processing.KubernetesResourceUtils.getVersion;
|
@@ -186,16 +185,8 @@ public Stream<T> getCachedCustomResources() {
|
186 | 185 | }
|
187 | 186 |
|
188 | 187 | public Stream<T> getCachedCustomResources(Predicate<T> predicate) {
|
189 |
| - var streamList = sharedIndexInformers.values().stream() |
190 |
| - .map(i -> i.getStore().list().stream().filter(predicate)).collect(Collectors.toList()); |
191 |
| - if (streamList.size() == 1) { |
192 |
| - return streamList.get(0); |
193 |
| - } |
194 |
| - var resStream = streamList.get(0); |
195 |
| - for (int i = 1; i < streamList.size(); i++) { |
196 |
| - resStream = Stream.concat(resStream, streamList.get(i)); |
197 |
| - } |
198 |
| - return resStream; |
| 188 | + return sharedIndexInformers.values().stream() |
| 189 | + .flatMap(i -> i.getStore().list().stream().filter(predicate)); |
199 | 190 | }
|
200 | 191 |
|
201 | 192 | /**
|
|
0 commit comments