Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/documentation/v5-0-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ permalink: /docs/v5-0-migration
---

# Migrating from v4.7 to v5.0

## API Tweaks

1. [Result of managed dependent resources](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/dependent/managed/ManagedDependentResourceContext.java#L55-L57)
is not `Optional` anymore. In case you use this result, simply use the result
objects directly.
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ public DefaultManagedDependentResourceContext setWorkflowCleanupResult(
}

@Override
public Optional<WorkflowReconcileResult> getWorkflowReconcileResult() {
return Optional.ofNullable(workflowReconcileResult);
public WorkflowReconcileResult getWorkflowReconcileResult() {
return workflowReconcileResult;
}

@Override
public Optional<WorkflowCleanupResult> getWorkflowCleanupResult() {
return Optional.ofNullable(workflowCleanupResult);
public WorkflowCleanupResult getWorkflowCleanupResult() {
return workflowCleanupResult;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public interface ManagedDependentResourceContext {
@SuppressWarnings("unused")
<T> T getMandatory(Object key, Class<T> expectedType);

Optional<WorkflowReconcileResult> getWorkflowReconcileResult();
WorkflowReconcileResult getWorkflowReconcileResult();

Optional<WorkflowCleanupResult> getWorkflowCleanupResult();
WorkflowCleanupResult getWorkflowCleanupResult();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import io.javaoperatorsdk.operator.api.reconciler.Reconciler;
import io.javaoperatorsdk.operator.api.reconciler.UpdateControl;
import io.javaoperatorsdk.operator.api.reconciler.dependent.Dependent;
import io.javaoperatorsdk.operator.processing.dependent.workflow.WorkflowReconcileResult;

@ControllerConfiguration(dependents = @Dependent(readyPostcondition = SampleBulkCondition.class,
type = CRUDConfigMapBulkDependentResource.class))
Expand All @@ -23,7 +22,8 @@ public UpdateControl<BulkDependentTestCustomResource> reconcile(
numberOfExecutions.incrementAndGet();

var ready = context.managedDependentResourceContext().getWorkflowReconcileResult()
.map(WorkflowReconcileResult::allDependentResourcesReady).orElseThrow();
.allDependentResourcesReady();


resource.setStatus(new BulkDependentTestStatus());
resource.getStatus().setReady(ready);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public UpdateControl<ComplexDependentCustomResource> reconcile(
ComplexDependentCustomResource resource,
Context<ComplexDependentCustomResource> context) throws Exception {
var ready = context.managedDependentResourceContext().getWorkflowReconcileResult()
.orElseThrow().allDependentResourcesReady();
.allDependentResourcesReady();

var status = Objects.requireNonNullElseGet(resource.getStatus(), ComplexDependentStatus::new);
status.setStatus(ready ? RECONCILE_STATUS.READY : RECONCILE_STATUS.NOT_READY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public UpdateControl<WorkflowAllFeatureCustomResource> reconcile(
resource.getStatus()
.setReady(
context.managedDependentResourceContext()
.getWorkflowReconcileResult().orElseThrow()
.getWorkflowReconcileResult()
.allDependentResourcesReady());
return UpdateControl.patchStatus(resource);
}
Expand Down