Skip to content

Commit 5757ada

Browse files
committed
Merge branch 'all-multi-resource-es' of github.com:java-operator-sdk/java-operator-sdk into all-multi-resource-es
2 parents 0d61e55 + 7325a94 commit 5757ada

File tree

3 files changed

+19
-26
lines changed

3 files changed

+19
-26
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/MultiResourceOwner.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ public interface IDMapper<R> {
55
String getID(R var1);
66

77
/**
8-
* Used If a polling event source handles only single secondary resource. See also docs for:
8+
* Used if a polling event source handles only single secondary resource. See also docs for:
99
* {@link ExternalResourceCachingEventSource}
1010
*
1111
* @return static id mapper, all resources are mapped for same id.
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
package io.javaoperatorsdk.operator.processing.event.source;
22

3+
import java.util.Optional;
4+
import java.util.Set;
5+
36
import io.fabric8.kubernetes.api.model.HasMetadata;
4-
import io.javaoperatorsdk.operator.processing.MultiResourceOwner;
7+
import io.javaoperatorsdk.operator.processing.ResourceOwner;
58

69
public interface ResourceEventSource<R, P extends HasMetadata> extends EventSource,
7-
MultiResourceOwner<R, P> {
10+
ResourceOwner<R, P> {
11+
12+
default Optional<R> getSecondaryResource(P primary) {
13+
var resources = getSecondaryResources(primary);
14+
if (resources.isEmpty()) {
15+
return Optional.empty();
16+
} else if (resources.size() == 1) {
17+
return Optional.of(resources.iterator().next());
18+
} else {
19+
throw new IllegalStateException("More than 1 secondary resource related to primary");
20+
}
21+
22+
}
823

24+
Set<R> getSecondaryResources(P primary);
925
}

0 commit comments

Comments
 (0)