Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Attila Mészáros <[email protected]>
  • Loading branch information
csviri committed May 23, 2024
1 parent ad232e4 commit 42120dd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ public abstract class CRUDKubernetesDependentResource<R extends HasMetadata, P e
public CRUDKubernetesDependentResource(Class<R> resourceType) {
super(resourceType);
}

public CRUDKubernetesDependentResource(Class<R> resourceType, String name) {
super(resourceType, name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ protected <R> void registerOrDeregisterEventSourceBasedOnActivation(
if (dependentResourceNode.getActivationCondition().isPresent()) {
final var dr = dependentResourceNode.getDependentResource();
final var eventSourceRetriever = context.eventSourceRetriever();
var eventSource =
dr.eventSource(eventSourceRetriever.eventSourceContextForDynamicRegistration());
if (activationConditionMet) {
var eventSource =
dr.eventSource(eventSourceRetriever.eventSourceContextForDynamicRegistration());
var es = eventSource.orElseThrow();
eventSourceRetriever.dynamicallyRegisterEventSource(es);
} else {
eventSourceRetriever.dynamicallyDeRegisterEventSource(dr.name());
eventSourceRetriever.dynamicallyDeRegisterEventSource(eventSource.orElseThrow().name());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;

import io.fabric8.kubernetes.api.model.ConfigMap;
import io.fabric8.kubernetes.api.model.ConfigMapBuilder;
import io.javaoperatorsdk.operator.api.reconciler.Context;
import io.javaoperatorsdk.operator.api.reconciler.EventSourceContext;
import io.javaoperatorsdk.operator.api.reconciler.dependent.Deleter;
import io.javaoperatorsdk.operator.api.reconciler.dependent.DependentResource;
import io.javaoperatorsdk.operator.api.reconciler.dependent.GarbageCollected;
import io.javaoperatorsdk.operator.api.reconciler.dependent.ReconcileResult;
import io.javaoperatorsdk.operator.processing.dependent.Creator;
import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependentResource;
import io.javaoperatorsdk.operator.processing.event.source.informer.InformerEventSource;
import io.javaoperatorsdk.operator.sample.simple.TestCustomResource;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class AbstractWorkflowExecutorTest {
public static final String VALUE = "value";

Expand Down Expand Up @@ -52,6 +58,14 @@ public ReconcileResult<ConfigMap> reconcile(TestCustomResource primary,
.resourceCreated(new ConfigMapBuilder().addToBinaryData("key", VALUE).build());
}

@Override
public synchronized Optional<InformerEventSource<ConfigMap, TestCustomResource>> eventSource(
EventSourceContext<TestCustomResource> context) {
var mockIES = mock(InformerEventSource.class);
when(mockIES.name()).thenReturn(name);
return Optional.of(mockIES);
}

@Override
public String toString() {
return name();
Expand Down

0 comments on commit 42120dd

Please sign in to comment.