Closed mtardy closed 3 weeks ago
I think it would be good to have this fixed. The problem is that many folks are compiling controller-gen themselves with ~ arbitrarily old Go versions :)
(I guess if we increase the Go min version in go.mod that would block them from compiling with old versions, but I think the fix would be good in any case)
Here is how to repro:
Create a a repro directory
mkdir repro
and putrepro.go
inside of it with:Run
controller-gen
with:The output should be similar to
Now bump the go directive to Go 1.23.0 in
go.mod
or putgodebug gotypesalias=1
in the go.mod with Go 1.22:Run
controller-gen
with:The output should be similar to
Explanation: without the type Alias being its own type (Go 1.22), in
localNamedToSchema
, the link is missing: https://github.com/kubernetes-sigs/controller-tools/blob/1d40d792491f708409229c554022de59b90637a7/pkg/crd/schema.go#L245-L254This patch would fix it https://github.com/cilium/controller-tools/commit/d944debcff34ea02a9506bc5911b2bb64ee61dd6.
When type Alias is its own type, it goes to: https://github.com/kubernetes-sigs/controller-tools/blob/1d40d792491f708409229c554022de59b90637a7/pkg/crd/schema.go#L255-L267
And then the link is properly made.
Should we have the patch for the version so that type Alias validation works with Go 1.22 or should we just wait for this project to use Go 1.23 and thus
gotypesalias=1
? Thanks!