-
Notifications
You must be signed in to change notification settings - Fork 218
feat: workflow Integration with API (dependent annotations, context) #1257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
2d3c111
feat: annotation config for workflow
csviri 7c40e1b
wip
csviri 5c62702
impl skeleton
csviri e344e77
wip
csviri 7ca2a9f
untit test for workflow utils
csviri 6a91a5d
workflow api integration
csviri 6916bb4
fixes
csviri b45a0e3
it fix
csviri 6af09ff
IT fix
csviri 88d81d0
renaming
csviri 9fb2ffb
refactors, tests
csviri 6e6d47a
wip
csviri 8e08769
additional unit tests
csviri 0e3693b
format
csviri 01b6ffd
updated samples
csviri 8d26095
IT wip
csviri c8fe351
IT wip
csviri 29c0062
test, and fixis with the consig service provider in tests
csviri a3c203d
renaming conditions
csviri 83aa6a5
sonar fixes
csviri 36b2501
sonar issue
csviri 639c414
refactor: avoid unneeded object creation
metacosm 682072c
refactor: improve readability
metacosm a654a74
refactor: checkForNameDuplication can now report all duplicates
metacosm 4b41176
refactor: rename more appropriately
metacosm e3771f2
refactor: no need for mock, makes things faster & easier to debug
metacosm b3dbfbd
chore(tests): add more tests
metacosm ff71f3b
refactor: simplify and make orderAndDetectCycles more readable
metacosm 18bdddf
refactor: avoid creating a ManagedWorkflow instance when not needed
metacosm 4b01cb8
fix: rename test to reflect use case
metacosm ad988b1
chore: format
metacosm 3f12362
ˆ
metacosm f8d3c16
fix: possible NPE
metacosm 9156441
moved javadoc
csviri 0b7dc97
Merge branch 'annotation-workflow' of github.com:java-operator-sdk/ja…
csviri e951058
comment in test
csviri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
14 changes: 14 additions & 0 deletions
14
...ore/src/main/java/io/javaoperatorsdk/operator/api/reconciler/dependent/VoidCondition.java
This file contains hidden or 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,14 @@ | ||
package io.javaoperatorsdk.operator.api.reconciler.dependent; | ||
|
||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.javaoperatorsdk.operator.api.reconciler.Context; | ||
import io.javaoperatorsdk.operator.processing.dependent.workflow.Condition; | ||
|
||
/** Used as default value for Condition in annotations */ | ||
@SuppressWarnings("rawtypes") | ||
public class VoidCondition implements Condition { | ||
@Override | ||
public boolean isMet(DependentResource dependentResource, HasMetadata primary, Context context) { | ||
throw new IllegalStateException("This is a placeholder class, should not be called"); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...sdk/operator/api/reconciler/dependent/managed/DefaultManagedDependentResourceContext.java
This file contains hidden or 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,61 @@ | ||
package io.javaoperatorsdk.operator.api.reconciler.dependent.managed; | ||
|
||
import java.util.Optional; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
import io.javaoperatorsdk.operator.processing.dependent.workflow.WorkflowCleanupResult; | ||
import io.javaoperatorsdk.operator.processing.dependent.workflow.WorkflowReconcileResult; | ||
|
||
@SuppressWarnings("rawtypes") | ||
public class DefaultManagedDependentResourceContext implements ManagedDependentResourceContext { | ||
|
||
private WorkflowReconcileResult workflowReconcileResult; | ||
private WorkflowCleanupResult workflowCleanupResult; | ||
private final ConcurrentHashMap attributes = new ConcurrentHashMap(); | ||
|
||
@Override | ||
public <T> Optional<T> get(Object key, Class<T> expectedType) { | ||
return Optional.ofNullable(attributes.get(key)) | ||
.filter(expectedType::isInstance) | ||
.map(expectedType::cast); | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("unchecked") | ||
public <T> T put(Object key, T value) { | ||
if (value == null) { | ||
return (T) Optional.ofNullable(attributes.remove(key)); | ||
} | ||
return (T) Optional.ofNullable(attributes.put(key, value)); | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("unused") | ||
public <T> T getMandatory(Object key, Class<T> expectedType) { | ||
return get(key, expectedType).orElseThrow(() -> new IllegalStateException( | ||
"Mandatory attribute (key: " + key + ", type: " + expectedType.getName() | ||
+ ") is missing or not of the expected type")); | ||
} | ||
|
||
public DefaultManagedDependentResourceContext setWorkflowExecutionResult( | ||
WorkflowReconcileResult workflowReconcileResult) { | ||
this.workflowReconcileResult = workflowReconcileResult; | ||
return this; | ||
} | ||
|
||
public DefaultManagedDependentResourceContext setWorkflowCleanupResult( | ||
WorkflowCleanupResult workflowCleanupResult) { | ||
this.workflowCleanupResult = workflowCleanupResult; | ||
return this; | ||
} | ||
|
||
@Override | ||
public Optional<WorkflowReconcileResult> getWorkflowReconcileResult() { | ||
return Optional.ofNullable(workflowReconcileResult); | ||
} | ||
|
||
@Override | ||
public Optional<WorkflowCleanupResult> getWorkflowCleanupResult() { | ||
return Optional.ofNullable(workflowCleanupResult); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the point of that change? See also comments on the associated test class…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this solves an issue with the integration tests, basically since it is singleton, it needs to be reseted after the integration tests. But if the DEFAULT is not created again (with this method in reset) , the configurations are for dependents stay in there and causes trouble. This is just for tests.
see: https://github.com/java-operator-sdk/java-operator-sdk/blob/0b7dc97de05df069e2db87384a9d1f67b3e79724/operator-framework-junit5/src/main/java/io/javaoperatorsdk/operator/junit/AbstractOperatorExtension.java#L165-L165
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 I guess the current
reset
implementation is indeed wrong…