Skip to content

Commit 09fa78f

Browse files
syscod3claude
andcommitted
feat(operator): register ImpVM/ImpVMClass/ImpVMTemplate admission webhooks
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7435716 commit 09fa78f

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

cmd/operator/main.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ import (
1111
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
1212
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
1313
ctrl "sigs.k8s.io/controller-runtime"
14+
"sigs.k8s.io/controller-runtime/pkg/builder"
1415
"sigs.k8s.io/controller-runtime/pkg/healthz"
1516
"sigs.k8s.io/controller-runtime/pkg/log/zap"
1617
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
1718

1819
impv1alpha1 "github.com/syscode-labs/imp/api/v1alpha1"
1920
"github.com/syscode-labs/imp/internal/controller"
21+
webhookv1alpha1 "github.com/syscode-labs/imp/internal/webhook/v1alpha1"
2022
)
2123

2224
var (
@@ -67,6 +69,28 @@ func main() {
6769
os.Exit(1)
6870
}
6971

72+
if err = builder.WebhookManagedBy(mgr, &impv1alpha1.ImpVM{}).
73+
WithDefaulter(&webhookv1alpha1.ImpVMWebhook{}).
74+
WithValidator(&webhookv1alpha1.ImpVMWebhook{}).
75+
Complete(); err != nil {
76+
setupLog.Error(err, "unable to register webhook", "webhook", "ImpVM")
77+
os.Exit(1)
78+
}
79+
80+
if err = builder.WebhookManagedBy(mgr, &impv1alpha1.ImpVMClass{}).
81+
WithValidator(&webhookv1alpha1.ImpVMClassWebhook{}).
82+
Complete(); err != nil {
83+
setupLog.Error(err, "unable to register webhook", "webhook", "ImpVMClass")
84+
os.Exit(1)
85+
}
86+
87+
if err = builder.WebhookManagedBy(mgr, &impv1alpha1.ImpVMTemplate{}).
88+
WithValidator(&webhookv1alpha1.ImpVMTemplateWebhook{}).
89+
Complete(); err != nil {
90+
setupLog.Error(err, "unable to register webhook", "webhook", "ImpVMTemplate")
91+
os.Exit(1)
92+
}
93+
7094
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
7195
setupLog.Error(err, "unable to set up health check")
7296
os.Exit(1)

0 commit comments

Comments
 (0)