@@ -33,13 +33,14 @@ import (
3333 "sigs.k8s.io/controller-runtime/pkg/webhook/admission"
3434)
3535
36- type FeatureFlagCustomValidator struct {
37- }
36+ type FeatureFlagCustomValidator struct {}
3837
3938// log is for logging in this package.
40- var featureFlagLog = logf .Log .WithName ("featureflag-resource validator" )
41- var compiledSchema * gojsonschema.Schema
42- var schemaInitOnce sync.Once
39+ var (
40+ featureFlagLog = logf .Log .WithName ("featureflag-resource validator" )
41+ compiledSchema * gojsonschema.Schema
42+ schemaInitOnce sync.Once
43+ )
4344
4445func (v * FeatureFlagCustomValidator ) SetupWebhookWithManager (mgr ctrl.Manager ) error {
4546 return ctrl .NewWebhookManagedBy (mgr ).
@@ -71,10 +72,10 @@ func (v *FeatureFlagCustomValidator) ValidateCreate(ctx context.Context, obj run
7172
7273// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
7374func (v * FeatureFlagCustomValidator ) ValidateUpdate (ctx context.Context , oldObj runtime.Object , newObj runtime.Object ) (warnings admission.Warnings , err error ) {
74- featureFlag , ok := oldObj .(* v1beta1.FeatureFlag )
75+ featureFlag , ok := newObj .(* v1beta1.FeatureFlag )
7576
7677 if ! ok {
77- return nil , fmt .Errorf ("expected a FeatureFlag object but got %T" , oldObj )
78+ return nil , fmt .Errorf ("expected a FeatureFlag object but got %T" , newObj )
7879 }
7980
8081 featureFlagLog .Info ("validate update" , "name" , featureFlag .Name )
@@ -135,7 +136,6 @@ func initSchemas() (*gojsonschema.Schema, error) {
135136 if err == nil {
136137 compiledSchema , err = schemaLoader .Compile (gojsonschema .NewStringLoader (schema .FlagSchema ))
137138 }
138-
139139 })
140140
141141 return compiledSchema , err
0 commit comments