Skip to content

Commit

Permalink
Do webhook registration earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
eberlep committed Sep 12, 2024
1 parent 0c647e5 commit 9be8298
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,17 @@ func main() {
}
// +kubebuilder:scaffold:builder

svcClusterMgr.GetWebhookServer().Register("/mutate-v1-sts", &webhook.Admission{Handler: &webhooks.FsGroupChangePolicySetter{SvcClient: svcClusterMgr.GetClient(), Decoder: admission.NewDecoder(svcClusterMgr.GetScheme()), Log: ctrl.Log.WithName("webhooks").WithName("FsGroupChangePolicySetter")}})

// svcClusterMgr.GetWebhookServer().Register("/mutate-v1-pod", &webhook.Admission{Handler: &webhooks.PodAnnotator{Client: svcClusterMgr.GetClient(), Decoder: admission.NewDecoder(svcClusterMgr.GetScheme()), Log: ctrl.Log.WithName("webhooks").WithName("PodAnnotator")}})
if err := builder.WebhookManagedBy(svcClusterMgr).
For(&corev1.Pod{}).
WithDefaulter(&webhooks.PodAnnotator{}).
Complete(); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "Pod")
os.Exit(1)
}

ctx := context.Background()

// update all existing operators to the current version
Expand All @@ -513,15 +524,4 @@ func main() {
os.Exit(1)
}

svcClusterMgr.GetWebhookServer().Register("/mutate-v1-sts", &webhook.Admission{Handler: &webhooks.FsGroupChangePolicySetter{SvcClient: svcClusterMgr.GetClient(), Decoder: admission.NewDecoder(svcClusterMgr.GetScheme()), Log: ctrl.Log.WithName("webhooks").WithName("FsGroupChangePolicySetter")}})

// svcClusterMgr.GetWebhookServer().Register("/mutate-v1-pod", &webhook.Admission{Handler: &webhooks.PodAnnotator{Client: svcClusterMgr.GetClient(), Decoder: admission.NewDecoder(svcClusterMgr.GetScheme()), Log: ctrl.Log.WithName("webhooks").WithName("PodAnnotator")}})
if err := builder.WebhookManagedBy(svcClusterMgr).
For(&corev1.Pod{}).
WithDefaulter(&webhooks.PodAnnotator{}).
Complete(); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "Pod")
os.Exit(1)
}

}

0 comments on commit 9be8298

Please sign in to comment.