INNER CODE UNIT · Go
webhookPath
kudobuilder/kudo · cmd/manager/main.go:201
func webhookPath(prefix string, obj runtime.Object, mgr manager.Manager) (string, error) {
gvk, err := apiutil.GVKForObject(obj, mgr.GetScheme())
if err != nil {
return "", err
}
// if the strategy to generate this path changes we should update init code and webhook setup
// right now this is in sync how controller-runtime generates these paths
return prefix + "-" + strings.ReplaceAll(gvk.Group, ".", "-") + "-" +
gvk.Version + "-" + strings.ToLower(gvk.Kind), nil
}
// isAlreadyHandled method check if there is already an admission webhook registered for a given path
func isAlreadyHandled(path string, mgr manager.Manager) bool {
if mgr.GetWebhookServer().WebhookMux == nil {
return false
}
h, p := mgr.GetWebhookServer().WebhookMux.Handler(&http.Request{URL: &url.URL{Path: path}})