From c065dc627e99481d294b9c9fe9bcfee9deb15cff Mon Sep 17 00:00:00 2001 From: Hemant Kumar Date: Wed, 15 Jul 2026 18:23:17 -0400 Subject: [PATCH] Fix fuzzer for defaults --- pkg/apis/storage/fuzzer/fuzzer.go | 4 +++ .../storage/validation/validation_test.go | 36 +++++++++---------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/pkg/apis/storage/fuzzer/fuzzer.go b/pkg/apis/storage/fuzzer/fuzzer.go index 9351a1dedc7..6b266d2a46a 100644 --- a/pkg/apis/storage/fuzzer/fuzzer.go +++ b/pkg/apis/storage/fuzzer/fuzzer.go @@ -100,6 +100,10 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { obj.Spec.SELinuxMount = new(bool) *(obj.Spec.SELinuxMount) = false } + if obj.Spec.PreventPodSchedulingIfMissing == nil { + obj.Spec.PreventPodSchedulingIfMissing = new(bool) + *(obj.Spec.PreventPodSchedulingIfMissing) = false + } }, } } diff --git a/pkg/apis/storage/validation/validation_test.go b/pkg/apis/storage/validation/validation_test.go index 5c2f91fb5c9..00f0aa7662c 100644 --- a/pkg/apis/storage/validation/validation_test.go +++ b/pkg/apis/storage/validation/validation_test.go @@ -2309,7 +2309,7 @@ func TestCSIDriverValidationSELinuxMountEnabledDisabled(t *testing.T) { }, { name: "feature enabled, non-nil value", featureEnabled: true, - seLinuxMountValue: ptr.To(true), + seLinuxMountValue: new(true), expectError: false, }, { name: "feature disabled, nil value", @@ -2319,7 +2319,7 @@ func TestCSIDriverValidationSELinuxMountEnabledDisabled(t *testing.T) { }, { name: "feature disabled, non-nil value", featureEnabled: false, - seLinuxMountValue: ptr.To(true), + seLinuxMountValue: new(true), expectError: false, }} for _, test := range tests { @@ -2331,10 +2331,10 @@ func TestCSIDriverValidationSELinuxMountEnabledDisabled(t *testing.T) { csiDriver := &storage.CSIDriver{ ObjectMeta: metav1.ObjectMeta{Name: "foo"}, Spec: storage.CSIDriverSpec{ - AttachRequired: ptr.To(true), - PodInfoOnMount: ptr.To(true), - RequiresRepublish: ptr.To(true), - StorageCapacity: ptr.To(true), + AttachRequired: new(true), + PodInfoOnMount: new(true), + RequiresRepublish: new(true), + StorageCapacity: new(true), SELinuxMount: test.seLinuxMountValue, PreventPodSchedulingIfMissing: new(false), }, @@ -2365,18 +2365,18 @@ func TestCSIDriverValidationSELinuxMountEnabledDisabled(t *testing.T) { name: "feature enabled, nil->set", featureEnabled: true, oldValue: nil, - newValue: ptr.To(true), + newValue: new(true), expectError: false, }, { name: "feature enabled, set->set", featureEnabled: true, - oldValue: ptr.To(true), - newValue: ptr.To(true), + oldValue: new(true), + newValue: new(true), expectError: false, }, { name: "feature enabled, set->nil", featureEnabled: true, - oldValue: ptr.To(true), + oldValue: new(true), newValue: nil, expectError: true, // populated by defaulting and required when feature is enabled }, { @@ -2389,18 +2389,18 @@ func TestCSIDriverValidationSELinuxMountEnabledDisabled(t *testing.T) { name: "feature disabled, nil->set", featureEnabled: false, oldValue: nil, - newValue: ptr.To(true), + newValue: new(true), expectError: false, }, { name: "feature disabled, set->set", featureEnabled: false, - oldValue: ptr.To(true), - newValue: ptr.To(true), + oldValue: new(true), + newValue: new(true), expectError: false, }, { name: "feature disabled, set->nil", featureEnabled: false, - oldValue: ptr.To(true), + oldValue: new(true), newValue: nil, expectError: false, }} @@ -2413,10 +2413,10 @@ func TestCSIDriverValidationSELinuxMountEnabledDisabled(t *testing.T) { oldCSIDriver := &storage.CSIDriver{ ObjectMeta: metav1.ObjectMeta{Name: "foo", ResourceVersion: "1"}, Spec: storage.CSIDriverSpec{ - AttachRequired: ptr.To(true), - PodInfoOnMount: ptr.To(true), - RequiresRepublish: ptr.To(true), - StorageCapacity: ptr.To(true), + AttachRequired: new(true), + PodInfoOnMount: new(true), + RequiresRepublish: new(true), + StorageCapacity: new(true), SELinuxMount: test.oldValue, PreventPodSchedulingIfMissing: new(false), },