code-generator
code-generator copied to clipboard
client-gen generates empty "core" group clientsets when "api" package directory is in use for input APIs
Last year we added a v4 project layout in Kubebuilder which utilizes api/ as the directory for APIs to better follow the package naming standards.
I have some kubebuilder-based projects where I am migrating from the v3 layout to the v4 layout. As part of this transition I'm moving my APIs from the apis/ directory to the api/ directory.
Using the latest main (da01854401d8e08e9b5dbccd9f1aad4ced83587f at the time of writing) the clientset generators break, emitting empty files to a core directory. It seems using api trips some special rules in client-gen.
I dug into the code and did some dlv debugging on this and found an assumption in the code:
https://github.com/kubernetes/code-generator/blob/da01854401d8e08e9b5dbccd9f1aad4ced83587f/cmd/client-gen/types/types.go#L44
func (g Group) NonEmpty() string {
if g == "api" {
return "core"
}
return string(g)
}
I understanding why that assumption exists for upstream, but given that Kubebuilder layout v4 now defaults to an api/ directory it seems like this might be problematic for downstream users.
During my debugging I was able to hack around this a bit to get something that emitted a working client for me, but I wanted to stop and mention this before trying to submit a patch to see if anyone had any thoughts on the matter, or some keen insights?