🐛 pkg/crd: support validation on type alias to basic types#1078
🐛 pkg/crd: support validation on type alias to basic types#1078k8s-ci-robot merged 2 commits intokubernetes-sigs:mainfrom
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. DetailsInstructions 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. DetailsGit 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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This closes off GHSA-qxp5-gwg8-xv66 Just a note that go 1.23 type alias breaks controller-tools code generation, so gotypesalias=0 is set to keep the same behavior in go 1.22. Relates: kubernetes-sigs/controller-tools#1078 Relates: #35406 Signed-off-by: Feroz Salam <feroz.salam@isovalent.com> Signed-off-by: Tam Mach <tam.mach@cilium.io>
This closes off GHSA-qxp5-gwg8-xv66 Just a note that go 1.23 type alias breaks controller-tools code generation, so gotypesalias=0 is set to keep the same behavior in go 1.22. Relates: kubernetes-sigs/controller-tools#1078 Relates: #35406 Signed-off-by: Feroz Salam <feroz.salam@isovalent.com> Signed-off-by: Tam Mach <tam.mach@cilium.io>
This resolves GHSA-qxp5-gwg8-xv66 Just a note that go 1.23 type alias breaks controller-tools code generation, so gotypesalias=0 is set to keep the same behavior in go 1.22. Relates: kubernetes-sigs/controller-tools#1078 Relates: #35406 Signed-off-by: Feroz Salam <feroz.salam@isovalent.com> Co-authored-by: Tam Mach <tam.mach@cilium.io>
This closes off GHSA-qxp5-gwg8-xv66 Just a note that go 1.23 type alias breaks controller-tools code generation, so gotypesalias=0 is set to keep the same behavior in go 1.22. Relates: kubernetes-sigs/controller-tools#1078 Relates: #35406 Signed-off-by: Feroz Salam <feroz.salam@isovalent.com> Signed-off-by: Tam Mach <tam.mach@cilium.io>
This resolves GHSA-qxp5-gwg8-xv66 Just a note that go 1.23 type alias breaks controller-tools code generation, so gotypesalias=0 is set to keep the same behavior in go 1.22. Relates: kubernetes-sigs/controller-tools#1078 Relates: #35406 Signed-off-by: Feroz Salam <feroz.salam@isovalent.com> Co-authored-by: Tam Mach <tam.mach@cilium.io>
This resolves GHSA-qxp5-gwg8-xv66 Just a note that go 1.23 type alias breaks controller-tools code generation, so gotypesalias=0 is set to keep the same behavior in go 1.22. Relates: kubernetes-sigs/controller-tools#1078 Relates: #35406 Signed-off-by: Feroz Salam <feroz.salam@isovalent.com> Co-authored-by: Tam Mach <tam.mach@cilium.io>
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.