Skip to content

Commit f8b6dc6

Browse files
committed
wip
Signed-off-by: Attila Mészáros <[email protected]>
1 parent 470dd2d commit f8b6dc6

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package io.javaoperatorsdk.operator.api.reconciler;
2+
3+
import io.fabric8.kubernetes.api.model.HasMetadata;
4+
import io.javaoperatorsdk.operator.processing.event.ResourceID;
5+
6+
public class PrimaryUpdateAndCacheUtils {
7+
8+
public static <P extends HasMetadata> P updateAndCacheStatus(P primary, Context<P> context) {
9+
if (primary.getMetadata().getResourceVersion() == null) {
10+
throw new IllegalStateException(
11+
"Primary resource version is null, it is expected to set resource version for updates"
12+
+ " with for cache");
13+
}
14+
var updatedResource = context.getClient().resource(primary).updateStatus();
15+
context
16+
.eventSourceRetriever()
17+
.getControllerEventSource()
18+
.handleRecentResourceUpdate(ResourceID.fromResource(primary), updatedResource, primary);
19+
return updatedResource;
20+
}
21+
22+
public static <P extends HasMetadata> P patchAndCacheStatus(P primary) {
23+
return null;
24+
}
25+
}

Diff for: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/support/ResourceCache.java renamed to operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/support/ResourceCache.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.javaoperatorsdk.operator.processing.support;
1+
package io.javaoperatorsdk.operator.api.reconciler.support;
22

33
import java.util.concurrent.ConcurrentHashMap;
44
import java.util.function.BiPredicate;

Diff for: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/EventSourceManager.java

+1
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ public Stream<? extends EventSource<?, P>> getEventSourcesStream() {
208208
return eventSources.flatMappedSources();
209209
}
210210

211+
@Override
211212
public ControllerEventSource<P> getControllerEventSource() {
212213
return eventSources.controllerEventSource();
213214
}

Diff for: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/EventSourceRetriever.java

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import io.fabric8.kubernetes.api.model.HasMetadata;
77
import io.javaoperatorsdk.operator.api.reconciler.EventSourceContext;
88
import io.javaoperatorsdk.operator.processing.event.source.EventSource;
9+
import io.javaoperatorsdk.operator.processing.event.source.controller.ControllerEventSource;
910

1011
public interface EventSourceRetriever<P extends HasMetadata> {
1112

@@ -17,6 +18,8 @@ default <R> EventSource<R, P> getEventSourceFor(Class<R> dependentType) {
1718

1819
<R> List<EventSource<R, P>> getEventSourcesFor(Class<R> dependentType);
1920

21+
ControllerEventSource<P> getControllerEventSource();
22+
2023
/**
2124
* Registers (and starts) the specified {@link EventSource} dynamically during the reconciliation.
2225
* If an EventSource is already registered with the specified name, the registration will be

0 commit comments

Comments
 (0)