-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Define CRD field validation policy #7634
Comments
@sbueringer: This issue is currently awaiting triage. If CAPI contributors determines this is a relevant issue, they will accept it by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Related discussion at #6398 (Maybe should be closed in favor of this one?) |
Hm damn. Forgot we had the other issue. I'll re-read it when I get to it and then make a suggestion what we should do with it Thx for bringing up the other issue!! |
The testing side of this could use some expansion IMO. In other projects I work on we have managed to leverage envtest effectively to test validations of the OpenAPI schemas from a user perspective (ie from the YAML representation). We have also used it to test the validations from a Go perspective (because Go serialisation also matters). Yes with the webhooks we can write unit tests for the webhook code, but as this project already uses a lot of envtest for integration tests, I don't see the testing as a blocker for using openapi validations.
Some examples here would be helpful, what validations are we making today that cannot be achieved using CEL now that it's been introduced. A really good example of where CEL is a clear winner is in the case of a discriminated union. There's a KEP for implementing validation for this for CRDs but that's no implemented yet, in the mean time, the validation of a large discriminated union in Go is ugly (I've tried!), but in CEL, you need one ternary per member field and you're away. The example I've linked is at the struct level because it validates multiple fields within the struct, so this shows how option 3 might look I guess |
/triage accepted |
It's on my list |
This issue has not been updated in over 1 year, and should be re-triaged. You can:
For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/ /remove-triage accepted |
/priority important-longterm |
closing in favour of #6398 which have much more discussions on the same topic |
@fabriziopandini: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
As of today we have 95%+ of our field validation in webhook code.
We did this mostly because:
This has the following downsides:
I think we need a clear policy going forward about where and how the validation should be done.
Additional context
Options
I see at least the following options:
My opinion
I personally think 1. is the best option because:
/kind documentation
The text was updated successfully, but these errors were encountered: