mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-20 09:33:52 +00:00
Pass new and old object to DropDisabledFields
This commit is contained in:
@@ -24,8 +24,11 @@ import (
|
||||
|
||||
// DropDisabledFields removes disabled fields from the pvc spec.
|
||||
// This should be called from PrepareForCreate/PrepareForUpdate for all resources containing a pvc spec.
|
||||
func DropDisabledFields(pvcSpec *core.PersistentVolumeClaimSpec) {
|
||||
func DropDisabledFields(pvcSpec, oldPVCSpec *core.PersistentVolumeClaimSpec) {
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(features.BlockVolume) {
|
||||
pvcSpec.VolumeMode = nil
|
||||
if oldPVCSpec != nil {
|
||||
oldPVCSpec.VolumeMode = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ func TestDropAlphaPVCVolumeMode(t *testing.T) {
|
||||
// Enable alpha feature BlockVolume
|
||||
defer utilfeaturetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.BlockVolume, true)()
|
||||
// now test dropping the fields - should not be dropped
|
||||
DropDisabledFields(&pvc.Spec)
|
||||
DropDisabledFields(&pvc.Spec, nil)
|
||||
|
||||
// check to make sure VolumeDevices is still present
|
||||
// if featureset is set to true
|
||||
@@ -50,7 +50,7 @@ func TestDropAlphaPVCVolumeMode(t *testing.T) {
|
||||
// Disable alpha feature BlockVolume
|
||||
defer utilfeaturetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.BlockVolume, false)()
|
||||
// now test dropping the fields
|
||||
DropDisabledFields(&pvc.Spec)
|
||||
DropDisabledFields(&pvc.Spec, nil)
|
||||
|
||||
// check to make sure VolumeDevices is nil
|
||||
// if featureset is set to false
|
||||
|
Reference in New Issue
Block a user