Skip to content
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

Merged
merged 2 commits into from
Nov 8, 2024
Merged

Conversation

metacosm
Copy link
Collaborator

@metacosm metacosm commented Nov 6, 2024

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]

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")
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator

@csviri csviri Nov 7, 2024

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?

Copy link
Collaborator Author

@metacosm metacosm Nov 7, 2024

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).

Copy link
Collaborator

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.

Copy link
Collaborator

@csviri csviri Nov 8, 2024

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)

Copy link
Collaborator Author

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.

@metacosm metacosm merged commit 07e744b into main Nov 8, 2024
20 checks passed
@metacosm metacosm deleted the fix-2561 branch November 8, 2024 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Confusing hard-coded v1 expectation for CRD Yamls
2 participants