-
Notifications
You must be signed in to change notification settings - Fork 32
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: add custom strfmt.Registry support #42
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: eddycharly 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 |
This is an interesting bug. In upstream apiserver, native k8s types do not undergo schema validation so the empty string was allowed. CRDs on the other hand do, and use I just tested this by making a CRD with a field with
So to fix this for native types causes CRD validation to be incorrect (unless we hardcoded some logic to decide which strfmt to use depending on the GVK, but thats not nice). I wonder if this is a bug that should be fixed upstream, so that in k8s CRDs are allowed to have empty |
I wondered the same. Dunno maybe it was done intentionally. |
I thought it was acceptable to allow providing a custom registry, WDYT ? |
Or maybe a registry provider that can return a registry depending on the resource being validated ? |
I dont think so, at least for a single registry, since the custom registry will either be wrong for native types, or wrong for CRDs. It would never be correct for both unless you provided a registry depending on the type.
Yeah, In the worst case scenario we can use the registry conditionally for native types, but I'd like to avoid that if we can. Unfortunately patching upstream seems the solution I can think of. |
You mean changing the format validator for |
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
PR needs rebase. 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. |
Closing, became useless with recent changes. |
This PR adds custom
strfmt.Registry
support.Format
byte
does not allow empty strings (see comes from https://github.com/asaskevich/govalidator/blob/a9d515a09cc289c60d55064edec5ef189859f172/patterns.go#L27).This makes the secret below invalid:
Now, one could supply it's own registry like this to workaround the problem: