From 536dac922707ec4a8ddb2be88964089f087fd709 Mon Sep 17 00:00:00 2001 From: Nikolay Demchuk Date: Thu, 6 Feb 2025 21:42:05 +1000 Subject: [PATCH] fixes Signed-off-by: Nikolay Demchuk --- images/webhooks/src/handlers/llvsValidator.go | 38 +------------------ 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/images/webhooks/src/handlers/llvsValidator.go b/images/webhooks/src/handlers/llvsValidator.go index fc494ea3..f36cb1c6 100644 --- a/images/webhooks/src/handlers/llvsValidator.go +++ b/images/webhooks/src/handlers/llvsValidator.go @@ -2,13 +2,9 @@ package handlers import ( "context" - cn "github.com/deckhouse/sds-node-configurator/api/v1alpha1" "github.com/slok/kubewebhook/v2/pkg/model" kwhvalidating "github.com/slok/kubewebhook/v2/pkg/webhook/validating" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" - "k8s.io/klog/v2" - mc "webhooks/api" ) const ( @@ -16,39 +12,7 @@ const ( ) func LLVSValidate(ctx context.Context, arReview *model.AdmissionReview, obj metav1.Object) (*kwhvalidating.ValidatorResult, error) { - llvs, ok := obj.(*cn.) - if !ok { - // If not a storage class just continue the validation chain(if there is one) and do nothing. - return &kwhvalidating.ValidatorResult{}, nil - } - - if arReview.UserInfo.Username == allowedUserName { - klog.Infof("User %s is allowed to manage NFS storage classes", arReview.UserInfo.Username) - return &kwhvalidating.ValidatorResult{Valid: true}, nil - } - - cl, err := NewKubeClient("") - if err != nil { - klog.Fatal(err) - } - - listClasses := &cn.NFSStorageClassList{} - err = cl.List(ctx, listClasses) - - if nsc.ObjectMeta.DeletionTimestamp == nil && arReview.Operation != "delete" && nsc.Spec.Connection.NFSVersion == "3" { - v3presents = true - } - - klog.Infof("NFSv3 NFSStorageClass exists: %t", v3presents) - - nfsModuleConfig := &mc.ModuleConfig{} - - err = cl.Get(ctx, types.NamespacedName{Name: sdsNodeConfiguratorModuleName, Namespace: ""}, nfsModuleConfig) - if err != nil { - klog.Fatal(err) - } - - return &kwhvalidating.ValidatorResult{Valid: true}, + return &kwhvalidating.ValidatorResult{Valid: false}, nil }