-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow returning additional information from conditions (#2426)
Fixes #2424. --------- Signed-off-by: Attila Mészáros <[email protected]> Signed-off-by: Chris Laprun <[email protected]> Co-authored-by: Attila Mészáros <[email protected]> Signed-off-by: Chris Laprun <[email protected]>
- Loading branch information
Showing
29 changed files
with
797 additions
and
283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...ain/java/io/javaoperatorsdk/operator/processing/dependent/workflow/ConditionWithType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.javaoperatorsdk.operator.processing.dependent.workflow; | ||
|
||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.javaoperatorsdk.operator.api.reconciler.Context; | ||
import io.javaoperatorsdk.operator.api.reconciler.dependent.DependentResource; | ||
|
||
class ConditionWithType<R, P extends HasMetadata, T> implements DetailedCondition<R, P, T> { | ||
private final Condition<R, P> condition; | ||
private final Type type; | ||
|
||
ConditionWithType(Condition<R, P> condition, Type type) { | ||
this.condition = condition; | ||
this.type = type; | ||
} | ||
|
||
public Type type() { | ||
return type; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public Result<T> detailedIsMet(DependentResource<R, P> dependentResource, P primary, | ||
Context<P> context) { | ||
if (condition instanceof DetailedCondition detailedCondition) { | ||
return detailedCondition.detailedIsMet(dependentResource, primary, context); | ||
} else { | ||
return Result | ||
.withoutResult(condition.isMet(dependentResource, primary, context)); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...rc/main/java/io/javaoperatorsdk/operator/processing/dependent/workflow/DefaultResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.javaoperatorsdk.operator.processing.dependent.workflow; | ||
|
||
public class DefaultResult<T> implements DetailedCondition.Result<T> { | ||
private final T result; | ||
private final boolean success; | ||
|
||
public DefaultResult(boolean success, T result) { | ||
this.result = result; | ||
this.success = success; | ||
} | ||
|
||
@Override | ||
public T getDetail() { | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean isSuccess() { | ||
return success; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return asString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.