-
Notifications
You must be signed in to change notification settings - Fork 218
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
feat: allow manually specifying CRDs in test extension #2569
Conversation
This is useful when using a contract-first approach where the Java classes are generated from the CRD instead of the reverse. Fixes #2561 Signed-off-by: Chris Laprun <[email protected]>
LocallyRunOperatorExtension operator = | ||
LocallyRunOperatorExtension.builder() | ||
.withReconciler(new TestReconciler()) | ||
.withCRDMapping(TestCR.class, "src/test/crd/test.crd") |
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.
Regarding this API, not sure if we need to specify the class here, that is rather limiting, if someone for example uses dynamic API does not have the class. It would be enough to have just the path to cover even that possibility.
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.
This feature is meant for people who use the contract-first approach so they would have the class handy and most likely wouldn't use generic resources but I guess we could use the CRD name instead of the CR 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.
I mean we can make it even cover even that case (So dynamic resources handling with GenericKubernetesResource
)
Why we need a name or any id ? cannot we have an API just with a path?
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.
Because that would imply parsing the file to check the name, which I would rather avoid. It also allows to potentially override a generated CRD with a manual one if needed (though, this probably is more of a corner case).
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.
Hmm, but should we rather parse the CRD and index it based on API version. And check if that is the same as resources API version mentioned in reconciler. (But always apply it even if there is no reconciler corresponding to it). This also delegates responsibility to the user to name it correctly, what we could definitely simplify in the background seamlessly.
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.
So basically I think we should parse the crd to have nicer API here. If you want I can do it in a separate PR. (But we should not release before)
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, please open a PR with that change.
Signed-off-by: Chris Laprun <[email protected]>
This is useful when using a contract-first approach where the Java
classes are generated from the CRD instead of the reverse.
Fixes #2561
Signed-off-by: Chris Laprun [email protected]