-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Path Configuration for Kubebuilder Webhook Markers for Core Types #4300
Comments
I have a proposal for this. Can I create a PR? |
Moreover, I can modify the scaffold a little bit to make the Core type default path looks like this:
instead of:
I don't know if it is a good idea |
Hi @damsien, I am not sure if we can use However, regards your specific case and this issue specifically we probably just need to change the condition for from Something like // +kubebuilder:webhook:{{ if ne .Resource.Webhooks.WebhookVersion "v1" }}webhookVersions={{"{"}}{{ .Resource.Webhooks.WebhookVersion }}{{"}"}},{{ end }}path=/validate-{{ if and .Resource.Core (eq .Resource.QualifiedGroup "core") }}{{ .Resource.Version }}-{{ lower .Resource.Kind }}{{ else }}{{ .QualifiedGroupWithDash }}-{{ .Resource.Version }}-{{ lower .Resource.Kind }}{{ end }},mutating=false,failurePolicy=fail,sideEffects=None,groups={{ if .Resource.Core }}""{{ else }}{{ .Resource.QualifiedGroup }}{{ end }},resources={{ .Resource.Plural }},verbs=create;update,versions={{ .Resource.Version }},name=v{{ lower .Resource.Kind }}-{{ .Resource.Version }}.kb.io,admissionReviewVersions={{ .AdmissionReviewVersions }} |
That's what I've done! Let me check for the core path and I'll tell you! |
/assign |
@camilamacedo86 I just tried and yes it does not work because of these lines in the Either I make a PR on the My PR for this issue (without including the core path "fix") is ready btw. |
Yes sure! I've made the PR #4301 |
What broke? What's expected?
Kubebuilder currently does not distinguish between Core Types within the
core
API group and Core Types in other groups (e.g.,apps
) when generating webhook paths. This affects the accuracy of thepath
configuration in generated webhook markers. For further information see the doc; https://book.kubebuilder.io/reference/using_an_external_resourceExpected Behavior
For Core Types with
Group
set tocore
:/validate--v1-kind
(e.g.,/validate--v1-pod
).For Core Types where
Group
is notcore
:/validate-groupname-v1-kind
(e.g.,/validate-apps-v1-deployment
forapps
group types likeDeployment
).Current Code Reference
This issue is present in the following line of code, where
.Resource.Core
is used to determine if the path should exclude the group name:https://github.com/kubernetes-sigs/kubebuilder/blob/master/pkg/plugins/golang/v4/scaffolds/internal/templates/webhooks/webhook.go#L201
Suggested Fix
core
group types are formatted without a group name.Reproducing this issue
Source: https://kubernetes.slack.com/archives/CAR30FCJZ/p1730954016456359
KubeBuilder (CLI) Version
4.3.0
PROJECT version
No response
Plugin versions
No response
Other versions
No response
Extra Labels
No response
The text was updated successfully, but these errors were encountered: