|
| 1 | +package io.javaoperatorsdk.operator.workflow.getnonactivesecondary; |
| 2 | + |
| 3 | +import java.util.concurrent.atomic.AtomicInteger; |
| 4 | + |
| 5 | +import io.fabric8.openshift.api.model.Route; |
| 6 | +import io.javaoperatorsdk.operator.api.reconciler.Context; |
| 7 | +import io.javaoperatorsdk.operator.api.reconciler.ControllerConfiguration; |
| 8 | +import io.javaoperatorsdk.operator.api.reconciler.Reconciler; |
| 9 | +import io.javaoperatorsdk.operator.api.reconciler.UpdateControl; |
| 10 | +import io.javaoperatorsdk.operator.api.reconciler.Workflow; |
| 11 | +import io.javaoperatorsdk.operator.api.reconciler.dependent.Dependent; |
| 12 | + |
| 13 | +@Workflow(dependents = { |
| 14 | + @Dependent(type = ConfigMapDependentResource.class), |
| 15 | + @Dependent(type = RouteDependentResource.class, |
| 16 | + activationCondition = FalseActivationCondition.class) |
| 17 | +}) |
| 18 | +@ControllerConfiguration |
| 19 | +public class WorkflowActivationConditionReconciler |
| 20 | + implements Reconciler<GetNonActiveSecondaryCustomResource> { |
| 21 | + |
| 22 | + private final AtomicInteger numberOfReconciliationExecution = new AtomicInteger(0); |
| 23 | + |
| 24 | + @Override |
| 25 | + public UpdateControl<GetNonActiveSecondaryCustomResource> reconcile( |
| 26 | + GetNonActiveSecondaryCustomResource resource, |
| 27 | + Context<GetNonActiveSecondaryCustomResource> context) { |
| 28 | + |
| 29 | + // should not throw an exception even if the condition is false |
| 30 | + var route = context.getSecondaryResource(Route.class); |
| 31 | + |
| 32 | + numberOfReconciliationExecution.incrementAndGet(); |
| 33 | + |
| 34 | + return UpdateControl.noUpdate(); |
| 35 | + } |
| 36 | + |
| 37 | + public int getNumberOfReconciliationExecution() { |
| 38 | + return numberOfReconciliationExecution.get(); |
| 39 | + } |
| 40 | +} |
0 commit comments