Pass new and old object to DropDisabledFields

This commit is contained in:
Jordan Liggitt
2018-12-18 17:50:22 -05:00
parent 88284f637b
commit 901ddba812
9 changed files with 28 additions and 18 deletions

View File

@@ -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
}
}
}

View File

@@ -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