diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/dependent/managed/DefaultManagedWorkflowAndDependentResourceContext.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/dependent/managed/DefaultManagedWorkflowAndDependentResourceContext.java index 0102b58d80..bf9ead4c97 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/dependent/managed/DefaultManagedWorkflowAndDependentResourceContext.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/dependent/managed/DefaultManagedWorkflowAndDependentResourceContext.java @@ -73,13 +73,13 @@ public T getMandatory(Object key, Class expectedType) { } @Override - public WorkflowReconcileResult getWorkflowReconcileResult() { - return getMandatory(RECONCILE_RESULT_KEY, WorkflowReconcileResult.class); + public Optional getWorkflowReconcileResult() { + return get(RECONCILE_RESULT_KEY, WorkflowReconcileResult.class); } @Override - public WorkflowCleanupResult getWorkflowCleanupResult() { - return getMandatory(CLEANUP_RESULT_KEY, WorkflowCleanupResult.class); + public Optional getWorkflowCleanupResult() { + return get(CLEANUP_RESULT_KEY, WorkflowCleanupResult.class); } @Override diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/dependent/managed/ManagedWorkflowAndDependentResourceContext.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/dependent/managed/ManagedWorkflowAndDependentResourceContext.java index 617505b387..0dfd323d9a 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/dependent/managed/ManagedWorkflowAndDependentResourceContext.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/dependent/managed/ManagedWorkflowAndDependentResourceContext.java @@ -61,10 +61,10 @@ public interface ManagedWorkflowAndDependentResourceContext { @SuppressWarnings("unused") T getMandatory(Object key, Class expectedType); - WorkflowReconcileResult getWorkflowReconcileResult(); + Optional getWorkflowReconcileResult(); @SuppressWarnings("unused") - WorkflowCleanupResult getWorkflowCleanupResult(); + Optional getWorkflowCleanupResult(); /** * Explicitly reconcile the declared workflow for the associated diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/dependent/bulkdependent/condition/ManagedBulkDependentWithReadyConditionReconciler.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/dependent/bulkdependent/condition/ManagedBulkDependentWithReadyConditionReconciler.java index 331d064b80..1dc48386cb 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/dependent/bulkdependent/condition/ManagedBulkDependentWithReadyConditionReconciler.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/dependent/bulkdependent/condition/ManagedBulkDependentWithReadyConditionReconciler.java @@ -23,6 +23,7 @@ public UpdateControl reconcile( numberOfExecutions.incrementAndGet(); var ready = context.managedWorkflowAndDependentResourceContext().getWorkflowReconcileResult() + .orElseThrow() .allDependentResourcesReady(); diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/dependent/bulkdependent/readonly/ReadOnlyBulkReconciler.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/dependent/bulkdependent/readonly/ReadOnlyBulkReconciler.java index 5a78f94be7..bec0823914 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/dependent/bulkdependent/readonly/ReadOnlyBulkReconciler.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/dependent/bulkdependent/readonly/ReadOnlyBulkReconciler.java @@ -16,6 +16,7 @@ public UpdateControl reconcile( var nonReadyDependents = context.managedWorkflowAndDependentResourceContext().getWorkflowReconcileResult() + .orElseThrow() .getNotReadyDependents(); diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/workflow/complexdependent/ComplexWorkflowReconciler.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/workflow/complexdependent/ComplexWorkflowReconciler.java index bab93d032e..d7e3fc56aa 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/workflow/complexdependent/ComplexWorkflowReconciler.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/workflow/complexdependent/ComplexWorkflowReconciler.java @@ -45,6 +45,7 @@ public UpdateControl reconcile( ComplexWorkflowCustomResource resource, Context context) throws Exception { var ready = context.managedWorkflowAndDependentResourceContext().getWorkflowReconcileResult() + .orElseThrow() .allDependentResourcesReady(); var status = Objects.requireNonNullElseGet(resource.getStatus(), ComplexWorkflowStatus::new); diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/workflow/workflowallfeature/WorkflowAllFeatureReconciler.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/workflow/workflowallfeature/WorkflowAllFeatureReconciler.java index c035a27375..fb8b0b4a3d 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/workflow/workflowallfeature/WorkflowAllFeatureReconciler.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/workflow/workflowallfeature/WorkflowAllFeatureReconciler.java @@ -43,12 +43,12 @@ public UpdateControl reconcile( } final var reconcileResult = context.managedWorkflowAndDependentResourceContext() .getWorkflowReconcileResult(); - final var msgFromCondition = reconcileResult.getDependentConditionResult( + final var msgFromCondition = reconcileResult.orElseThrow().getDependentConditionResult( DependentResource.defaultNameFor(ConfigMapDependentResource.class), Condition.Type.RECONCILE, String.class) .orElse(ConfigMapReconcileCondition.NOT_RECONCILED_YET); resource.getStatus() - .withReady(reconcileResult.allDependentResourcesReady()) + .withReady(reconcileResult.orElseThrow().allDependentResourcesReady()) .withMsgFromCondition(msgFromCondition); return UpdateControl.patchStatus(resource); } diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/workflow/workflowsilentexceptionhandling/HandleWorkflowExceptionsInReconcilerReconciler.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/workflow/workflowsilentexceptionhandling/HandleWorkflowExceptionsInReconcilerReconciler.java index d0a80d0be4..304c0d73ec 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/workflow/workflowsilentexceptionhandling/HandleWorkflowExceptionsInReconcilerReconciler.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/workflow/workflowsilentexceptionhandling/HandleWorkflowExceptionsInReconcilerReconciler.java @@ -25,7 +25,7 @@ public UpdateControl reconci Context context) { errorsFoundInReconcilerResult = context.managedWorkflowAndDependentResourceContext() - .getWorkflowReconcileResult().erroredDependentsExist(); + .getWorkflowReconcileResult().orElseThrow().erroredDependentsExist(); return UpdateControl.noUpdate(); @@ -36,7 +36,7 @@ public DeleteControl cleanup(HandleWorkflowExceptionsInReconcilerCustomResource Context context) { errorsFoundInCleanupResult = context.managedWorkflowAndDependentResourceContext() - .getWorkflowCleanupResult().erroredDependentsExist(); + .getWorkflowCleanupResult().orElseThrow().erroredDependentsExist(); return DeleteControl.defaultDelete(); }