-
Notifications
You must be signed in to change notification settings - Fork 416
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
client-gen generates empty "core" group clientsets when "api" package directory is in use for input APIs #167
Comments
Hi, I have the exact same issue with a default kubebuilder scaffolding. Actually, I was about to send this issue when I saw yours: Hi, The default kubebuilder scaffolding generated by:
results in the following files:
(with In order to generate a typed client for this API, I added
Indeed, The following workaround works, and a typed client for my resource is correctly generated:
It seems this is due to this line, which rewrites |
Thanks for adding on, I have a feeling this is probably a common problem for anyone using layout @camilamacedo86 I just wanted to ping you in here NOT because there's anything you need to do, but because I was working with you last in kubebuilder on the layout stuff a while back it seemed reasonable to assume you might wanna be aware of this problem. |
Hi @shaneutt Thank you for letting me know. IHMO is a bug/something that needs to be changed in the code generator. Kubebuilder officially supports the controller-gen since that is what we use by default, but it would be great if the code-generator could change that and work well with Kubebuilder. I know that some users have started to use it within. |
Hi @shaneutt,
Can a project work with both code-generator and controller-gen? Could you give a hand for us and raise an issue in the Kubebuilder like |
Sure sounds good, created: kubernetes-sigs/kubebuilder#3795 |
Hey folks, hope this is the right spot (first kubernetes issue for me) but I think there's another related issue to this. I'm using the V4 layout and my generated code is using the wrong API Path in the typed version client From
From my understanding, code-generator/cmd/client-gen/generators/generator_for_group.go Lines 74 to 79 in 07ba736
|
If client-go needs to keep the speicial conversion, what about adding a note in the argument flag? It's time-wasting for the user to figure it out by reading the implementation code. |
Also have to rename api/ to apis/, so that client-gen can work. See kubernetes/code-generator#167 The gateway-api also use apis/ as the directory to hold the CRD types, so I think this name is roburst enough in the k8s ecosystem. Signed-off-by: spacewander <[email protected]>
Also have to rename api/ to apis/, so that client-gen can work. See kubernetes/code-generator#167 The gateway-api also use apis/ as the directory to hold the CRD types, so I think this name is roburst enough in the k8s ecosystem. Signed-off-by: spacewander <[email protected]> --------- Signed-off-by: spacewander <[email protected]>
So, is not this one a bug? Thank you a lot |
I don't know why the author of code-generator added this conversion. Maybe they want to implement some compatibility. If removing this behavior is not possible, the other solution is to add a new argument to bypass this behavior. |
Hi @wojtek-t, @sttts, @deads2k Would be possible to change the conditional to allow users use it with Kubebuilder OR with any Golang project following the Golang Standard Layout (equally Kubebuilder) ? See https://github.com/golang-standards/project-layout?tab=readme-ov-file#service-application-directories (it is a good practice create our APIs and keep them in dir called code-generator/cmd/client-gen/generators/generator_for_group.go Lines 74 to 79 in 07ba736
In Kubebuilder we have mapped the core types in this way: I hope that can helps. Sorry I am not acquaintance well with this project. But could we not add this map in this part and check by the kind/group of each of them to know if is a core type or not? Thank you for your support and understanding. Cheers, |
kubernetes/kubernetes#125162 fixes this. |
As the FRR-K8s api is meant to be consumed by other controllers, we export the helpers so a pre-controller runtime controller can consume it. Note: the "core" symlink is to get around kubernetes/code-generator#167 Signed-off-by: Federico Paolinelli <[email protected]>
As the FRR-K8s api is meant to be consumed by other controllers, we export the helpers so a pre-controller runtime controller can consume it. Note: the "core" symlink is to get around kubernetes/code-generator#167 Signed-off-by: Federico Paolinelli <[email protected]>
As the FRR-K8s api is meant to be consumed by other controllers, we export the helpers so a pre-controller runtime controller can consume it. Note: the "core" symlink is to get around kubernetes/code-generator#167 Signed-off-by: Federico Paolinelli <[email protected]>
As the FRR-K8s api is meant to be consumed by other controllers, we export the helpers so a pre-controller runtime controller can consume it. Note: the "core" symlink is to get around kubernetes/code-generator#167 Signed-off-by: Federico Paolinelli <[email protected]>
As the FRR-K8s api is meant to be consumed by other controllers, we export the helpers so a pre-controller runtime controller can consume it. Note: the "core" symlink is to get around kubernetes/code-generator#167 Signed-off-by: Federico Paolinelli <[email protected]>
As the FRR-K8s api is meant to be consumed by other controllers, we export the helpers so a pre-controller runtime controller can consume it. Note: the "core" symlink is to get around kubernetes/code-generator#167 Signed-off-by: Federico Paolinelli <[email protected]>
As the FRR-K8s api is meant to be consumed by other controllers, we export the helpers so a pre-controller runtime controller can consume it. Note: the "core" symlink is to get around kubernetes/code-generator#167 Signed-off-by: Federico Paolinelli <[email protected]>
As the FRR-K8s api is meant to be consumed by other controllers, we export the helpers so a pre-controller runtime controller can consume it. Note: the "core" symlink is to get around kubernetes/code-generator#167 Signed-off-by: Federico Paolinelli <[email protected]>
As the FRR-K8s api is meant to be consumed by other controllers, we export the helpers so a pre-controller runtime controller can consume it. Note: the "core" symlink is to get around kubernetes/code-generator#167 Signed-off-by: Federico Paolinelli <[email protected]>
Last year we added a
v4
project layout in Kubebuilder which utilizesapi/
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 theapi/
directory.Using the latest main (da01854 at the time of writing) the clientset generators break, emitting empty files to a
core
directory. It seems usingapi
trips some special rules inclient-gen
.I dug into the code and did some
dlv
debugging on this and found an assumption in the code:code-generator/cmd/client-gen/types/types.go
Line 44 in da01854
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?
The text was updated successfully, but these errors were encountered: