@@ -27,7 +27,6 @@ import (
2727 "k8s.io/utils/pointer"
2828 ctrl "sigs.k8s.io/controller-runtime"
2929 logf "sigs.k8s.io/controller-runtime/pkg/log"
30- "sigs.k8s.io/controller-runtime/pkg/webhook"
3130 "sigs.k8s.io/controller-runtime/pkg/webhook/admission"
3231
3332 "github.com/project-codeflare/codeflare-operator/pkg/config"
@@ -39,7 +38,7 @@ var rayclusterlog = logf.Log.WithName("raycluster-resource")
3938func SetupRayClusterWebhookWithManager (mgr ctrl.Manager , cfg * config.KubeRayConfiguration ) error {
4039 return ctrl .NewWebhookManagedBy (mgr ).
4140 For (& rayv1.RayCluster {}).
42- WithDefaulter (& rayClusterDefaulter {
41+ WithDefaulter (& rayClusterWebhook {
4342 Config : cfg ,
4443 }).
4544 WithValidator (& rayClusterWebhook {
@@ -51,21 +50,15 @@ func SetupRayClusterWebhookWithManager(mgr ctrl.Manager, cfg *config.KubeRayConf
5150// +kubebuilder:webhook:path=/mutate-ray-io-v1-raycluster,mutating=true,failurePolicy=fail,sideEffects=None,groups=ray.io,resources=rayclusters,verbs=create;update,versions=v1,name=mraycluster.kb.io,admissionReviewVersions=v1
5251// +kubebuilder:webhook:path=/validate-ray-io-v1-raycluster,mutating=false,failurePolicy=fail,sideEffects=None,groups=ray.io,resources=rayclusters,verbs=create;update,versions=v1,name=vraycluster.kb.io,admissionReviewVersions=v1
5352
54- type rayClusterDefaulter struct {
55- Config * config.KubeRayConfiguration
56- }
5753type rayClusterWebhook struct {
5854 Config * config.KubeRayConfiguration
5955}
6056
61- var _ webhook.CustomDefaulter = & rayClusterDefaulter {}
62- var _ webhook.CustomValidator = & rayClusterWebhook {}
63-
6457// Default implements webhook.Defaulter so a webhook will be registered for the type
65- func (r * rayClusterDefaulter ) Default (ctx context.Context , obj runtime.Object ) error {
58+ func (w * rayClusterWebhook ) Default (ctx context.Context , obj runtime.Object ) error {
6659 raycluster := obj .(* rayv1.RayCluster )
6760
68- if ! pointer .BoolDeref (r .Config .RayDashboardOAuthEnabled , true ) {
61+ if ! pointer .BoolDeref (w .Config .RayDashboardOAuthEnabled , true ) {
6962 return nil
7063 }
7164
@@ -143,7 +136,7 @@ func (r *rayClusterDefaulter) Default(ctx context.Context, obj runtime.Object) e
143136 return nil
144137}
145138
146- func (v * rayClusterWebhook ) ValidateCreate (ctx context.Context , obj runtime.Object ) (admission.Warnings , error ) {
139+ func (w * rayClusterWebhook ) ValidateCreate (ctx context.Context , obj runtime.Object ) (admission.Warnings , error ) {
147140 raycluster := obj .(* rayv1.RayCluster )
148141 var warnings admission.Warnings
149142 var allErrors field.ErrorList
@@ -157,17 +150,17 @@ func (v *rayClusterWebhook) ValidateCreate(ctx context.Context, obj runtime.Obje
157150 return warnings , allErrors .ToAggregate ()
158151}
159152
160- func (v * rayClusterWebhook ) ValidateUpdate (ctx context.Context , oldObj , newObj runtime.Object ) (admission.Warnings , error ) {
153+ func (w * rayClusterWebhook ) ValidateUpdate (ctx context.Context , oldObj , newObj runtime.Object ) (admission.Warnings , error ) {
161154 newRayCluster := newObj .(* rayv1.RayCluster )
162155 if ! newRayCluster .DeletionTimestamp .IsZero () {
163156 // Object is being deleted, skip validations
164157 return nil , nil
165158 }
166- warnings , err := v .ValidateCreate (ctx , newRayCluster )
159+ warnings , err := w .ValidateCreate (ctx , newRayCluster )
167160 return warnings , err
168161}
169162
170- func (v * rayClusterWebhook ) ValidateDelete (ctx context.Context , obj runtime.Object ) (admission.Warnings , error ) {
163+ func (w * rayClusterWebhook ) ValidateDelete (ctx context.Context , obj runtime.Object ) (admission.Warnings , error ) {
171164 // Optional: Add delete validation logic here
172165 return nil , nil
173166}
0 commit comments