-
Notifications
You must be signed in to change notification settings - Fork 593
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
The fake clientset does not work as expected #3517
Comments
Thanks for your report @robertmarsal! This is actually interesting and it seems we have to be doing something not 100% correct. I've looked at other projects that generate clientsets e.g. Gateway API and Knative's serving and they both don't use the group name in their packages import path, e.g.
Yet they do get the full group name generated in the fake clients, e.g.
I've tried playing around with I've tried setting the These are the options I've used with not much of an effect:
What you're proposing would warrant a breaking changes release which we're not looking at right now (but we might at some point). So trying to figure this out just like the other projects did this would be they preferred solution. |
@pmalek thank you for the feedback! It pointed me in the right direction and I noticed that the I've created the PR #3621 with the fix. |
Is there an existing issue for this?
Current Behavior
Trying to use the fake client set to write some unit tests:
Where
kongv1
is the following import:kongv1 "github.com/kong/kubernetes-ingress-controller/v2/pkg/apis/configuration/v1"
Calling
returns an error that the plugin can not be found. This is because the group of the fake generated resources is wrong: https://github.com/Kong/kubernetes-ingress-controller/blob/main/pkg/clientset/typed/configuration/v1/fake/fake_kongplugin.go#L39. It should be
configuration.konghq.com
instead ofconfiguration
It looks like
client-gen
uses the folder structure to determine the group and at the moment it's set toconfiguration
: https://github.com/Kong/kubernetes-ingress-controller/tree/main/pkg/apis/configurationRenaming the folder to
configuration.konghq.com
and reruningclient-gen
generates the correct groups. I am not sure if having the wrong name for the folder has other impacts I've only noticed this when trying to use it for testing.Renaming that folder seems to break the public API though so I was not sure if it was an acceptable solution. I haven't seen any ways around it with the
client-gen
optionsExpected Behavior
The fake simple client set can be used for testing.
Steps To Reproduce
Kong Ingress Controller version
Kubernetes version
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: