|
3 | 3 | import java.util.*;
|
4 | 4 |
|
5 | 5 | import io.fabric8.kubernetes.api.model.HasMetadata;
|
6 |
| -import io.javaoperatorsdk.operator.api.reconciler.dependent.DependentResource; |
7 |
| -import io.javaoperatorsdk.operator.processing.dependent.workflow.Workflow; |
8 | 6 | import io.javaoperatorsdk.operator.processing.event.source.EventSource;
|
9 |
| -import io.javaoperatorsdk.operator.processing.event.source.ResourceEventSource; |
10 | 7 |
|
11 | 8 | public interface Reconciler<P extends HasMetadata> {
|
12 | 9 |
|
@@ -35,63 +32,4 @@ default Map<String, EventSource> prepareEventSources(EventSourceContext<P> conte
|
35 | 32 | return Map.of();
|
36 | 33 | }
|
37 | 34 |
|
38 |
| - /** |
39 |
| - * Utility method to easily create map with generated name for event sources. This is for the use |
40 |
| - * case when the event sources are not access explicitly by name in the reconciler. |
41 |
| - * |
42 |
| - * @param eventSources to name |
43 |
| - * @return even source with default names |
44 |
| - */ |
45 |
| - static Map<String, EventSource> nameEventSources(EventSource... eventSources) { |
46 |
| - Map<String, EventSource> eventSourceMap = new HashMap<>(eventSources.length); |
47 |
| - for (EventSource eventSource : eventSources) { |
48 |
| - eventSourceMap.put(generateNameFor(eventSource), eventSource); |
49 |
| - } |
50 |
| - return eventSourceMap; |
51 |
| - } |
52 |
| - |
53 |
| - @SuppressWarnings("unchecked") |
54 |
| - static <K extends HasMetadata> Map<String, EventSource> eventSourcesFromWorkflow( |
55 |
| - EventSourceContext<K> context, |
56 |
| - Workflow<K> workflow) { |
57 |
| - Map<String, EventSource> result = new HashMap<>(); |
58 |
| - for (var e : workflow.getDependentResourcesByNameWithoutActivationCondition().entrySet()) { |
59 |
| - var eventSource = e.getValue().eventSource(context); |
60 |
| - eventSource.ifPresent(es -> result.put(e.getKey(), (EventSource) es)); |
61 |
| - } |
62 |
| - return result; |
63 |
| - } |
64 |
| - |
65 |
| - @SuppressWarnings("rawtypes") |
66 |
| - static <K extends HasMetadata> Map<String, EventSource> nameEventSourcesFromDependentResource( |
67 |
| - EventSourceContext<K> context, DependentResource... dependentResources) { |
68 |
| - return nameEventSourcesFromDependentResource(context, Arrays.asList(dependentResources)); |
69 |
| - } |
70 |
| - |
71 |
| - @SuppressWarnings("unchecked,rawtypes") |
72 |
| - static <K extends HasMetadata> Map<String, EventSource> nameEventSourcesFromDependentResource( |
73 |
| - EventSourceContext<K> context, Collection<DependentResource> dependentResources) { |
74 |
| - |
75 |
| - if (dependentResources != null) { |
76 |
| - Map<String, EventSource> eventSourceMap = new HashMap<>(dependentResources.size()); |
77 |
| - for (DependentResource dependentResource : dependentResources) { |
78 |
| - Optional<ResourceEventSource> es = dependentResource.eventSource(context); |
79 |
| - es.ifPresent(e -> eventSourceMap.put(generateNameFor(e), e)); |
80 |
| - } |
81 |
| - return eventSourceMap; |
82 |
| - } else { |
83 |
| - return Collections.emptyMap(); |
84 |
| - } |
85 |
| - } |
86 |
| - |
87 |
| - /** |
88 |
| - * Used when event sources are not explicitly named when created/registered. |
89 |
| - * |
90 |
| - * @param eventSource EventSource |
91 |
| - * @return generated name |
92 |
| - */ |
93 |
| - static String generateNameFor(EventSource eventSource) { |
94 |
| - // we can have multiple event sources for the same class |
95 |
| - return eventSource.getClass().getName() + "#" + eventSource.hashCode(); |
96 |
| - } |
97 | 35 | }
|
0 commit comments