-
Notifications
You must be signed in to change notification settings - Fork 444
✨ Add k8s:required and k8s:optional markers #1247
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
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lalitc375 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @lalitc375. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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-sigs/prow repository. |
This commit introduces `k8s:required` and `k8s:optional` markers to align with the declarative validation KEP. These markers serve as a Kubernetes-style alternative to the existing `+required` and `+optional` markers for marking CRD fields. This change allows controller-gen to better understand native types in CRDs, improving the declarative validation process. Reference: https://github.com/kubernetes/enhancements/blob/master/keps/sig-api-machinery/5073-declarative-validation-with-validation-gen/README.md
/assign @JoelSpeed |
Is the intention in native types that this will replace the existing Do we expect to see only I'm keen to see that the community settle on choices that bring consistency, but that also includes among codebases. In the [kube-api-linter](https://github.com/kubernetes-sigs/kube-api-linter] project, we recommend folks to replace CC @yongruilin |
So, +optional/+required are not the same as of +k8s:optional/+k8s:required for native types. But these are the same for CRD's. We will the same situation while adding support for k8s:listType and k8s:listMapKey
For CRD's, both are the same thing, so one is sufficient. We can recommend devs to use the new ones only. For native types, we have to make sure the +k8s:optional/+k8s:required has the same behaviour as of existing ones for the openAPI required property, before making that recommendation.
I totally agree with you on the consistency part, Kubelinter should recommend the new ones, once the features are complete. |
Do we have an estimated timeline for the declarative validation project to be stable enough that there's no going back? I understand at the moment that it's all gated and could all be taken out should the project stall. If we add these markers to controller-tools now, I'd expect we do something similar where we have an easy way to back out of the declarative validation markers in the future, could we put them behind a feature flag for now? |
This commit introduces two new markers, k8s:required and k8s:optional, to allow marking fields in CRDs as required or
optional.
These IDL tags are introduced as part of the KEP for declarative validation: https://github.com/kubernetes/enhancements/blob/master/keps/sig-api-machinery/5073-declarative-validation-with-validation-gen/README.md
Adding this in controller-gen will allow understanding native types much better in CRDs.