|
13 | 13 | import io.javaoperatorsdk.operator.processing.event.Event;
|
14 | 14 | import io.javaoperatorsdk.operator.processing.event.ResourceID;
|
15 | 15 |
|
16 |
| -public class InformerEventSource<T extends HasMetadata> extends AbstractEventSource { |
| 16 | +public class InformerEventSource<T extends HasMetadata, P extends HasMetadata> |
| 17 | + extends AbstractEventSource<P> { |
17 | 18 |
|
18 | 19 | private static final Logger log = LoggerFactory.getLogger(InformerEventSource.class);
|
19 | 20 |
|
20 | 21 | private final SharedInformer<T> sharedInformer;
|
21 |
| - private final PrimaryResourcesRetriever<T> associatedPrimaries; |
22 |
| - private final AssociatedSecondaryRetriever<T> associatedWith; |
| 22 | + private final PrimaryResourcesRetriever<T, P> associatedPrimaries; |
| 23 | + private final AssociatedSecondaryRetriever<T, P> associatedWith; |
23 | 24 | private final boolean skipUpdateEventPropagationIfNoChange;
|
24 | 25 | private final ResourceCache<T> cache;
|
25 | 26 |
|
26 | 27 | public InformerEventSource(SharedInformer<T> sharedInformer,
|
27 |
| - PrimaryResourcesRetriever<T> associatedPrimaries, Cloner cloner) { |
| 28 | + PrimaryResourcesRetriever<T, P> associatedPrimaries, Cloner cloner) { |
28 | 29 | this(sharedInformer, associatedPrimaries, null, true, cloner);
|
29 | 30 | }
|
30 | 31 |
|
31 | 32 | public InformerEventSource(KubernetesClient client, Class<T> type,
|
32 |
| - PrimaryResourcesRetriever<T> associatedPrimaries, Cloner cloner) { |
| 33 | + PrimaryResourcesRetriever<T, P> associatedPrimaries, Cloner cloner) { |
33 | 34 | this(client, type, associatedPrimaries, false, cloner);
|
34 | 35 | }
|
35 | 36 |
|
36 | 37 | InformerEventSource(KubernetesClient client, Class<T> type,
|
37 |
| - PrimaryResourcesRetriever<T> associatedPrimaries, |
| 38 | + PrimaryResourcesRetriever<T, P> associatedPrimaries, |
38 | 39 | boolean skipUpdateEventPropagationIfNoChange, Cloner cloner) {
|
39 | 40 | this(client.informers().sharedIndexInformerFor(type, 0), associatedPrimaries, null,
|
40 | 41 | skipUpdateEventPropagationIfNoChange, cloner);
|
41 | 42 | }
|
42 | 43 |
|
43 | 44 | public InformerEventSource(SharedInformer<T> sharedInformer,
|
44 |
| - PrimaryResourcesRetriever<T> associatedPrimaries, |
45 |
| - AssociatedSecondaryRetriever<T> associatedWith, |
| 45 | + PrimaryResourcesRetriever<T, P> associatedPrimaries, |
| 46 | + AssociatedSecondaryRetriever<T, P> associatedWith, |
46 | 47 | boolean skipUpdateEventPropagationIfNoChange,
|
47 | 48 | Cloner cloner) {
|
48 | 49 | this.sharedInformer = sharedInformer;
|
@@ -121,7 +122,7 @@ public ResourceCache<T> getCache() {
|
121 | 122 | * @param resource the primary resource we want to retrieve the associated resource for
|
122 | 123 | * @return the informed resource associated with the specified primary resource
|
123 | 124 | */
|
124 |
| - public T getAssociated(HasMetadata resource) { |
| 125 | + public T getAssociated(P resource) { |
125 | 126 | return associatedWith.associatedSecondary(resource, eventSourceRegistry);
|
126 | 127 | }
|
127 | 128 |
|
|
0 commit comments