-
Notifications
You must be signed in to change notification settings - Fork 428
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
🐛 pkg/crd: support validation on type alias to basic types #1078
🐛 pkg/crd: support validation on type alias to basic types #1078
Conversation
Hi @mtardy. 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. |
Without the type Alias being its own type (Go 1.22 see gotypesalias), in localNamedToSchema, the link is missing. [ Upstream port of cilium/controller-tools@d944debcff34 ("Support type aliasing to basic types") ] Previously, validation schema generation was skipped on a type alias: type A = B Whereas, a new type was fine: type A B This commit implements support for generating validation schemas for type aliases to basic types, i.e. string, int, etc. Co-authored-by: Chris Tarazi <tarazichris@gmail.com> Signed-off-by: Mahe Tardy <mahe.tardy@gmail.com>
This patch will be needed when upgrading to Go 1.23 as type alias now generate a proper type (instead of directly being the basic type they alias to), see https://pkg.go.dev/go/types#Alias for more info. This just reproduces the old behavior by retrieving the underlying type from the alias. If needed, we could treat alias more gracefully to make the type ref link now that we have all the type information. Signed-off-by: Mahe Tardy <mahe.tardy@gmail.com>
fc92564
to
e443da3
Compare
/cc @sbueringer Since you commented here #1071 (comment). |
/ok-to-test |
Thank you very much!! /lgtm |
LGTM label has been added. Git tree hash: 8cde2ff060f2cedfdd25b0ed7bcbb387098d501d
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mtardy, sbueringer The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fixes #1071
Without the type Alias being its own type (Go 1.22 see gotypesalias), in localNamedToSchema, the link is missing.
[ Upstream port of d944deb ("Support type aliasing to basic types") ]
Previously, validation schema generation was skipped on a type alias:
Whereas, a new type was fine:
This commit implements support for generating validation schemas for type aliases to basic types, i.e. string, int, etc.