Update unit tests and feature name

Update the unit tests to include checks for incorrect APIGroup type in
PVC DataSource and change the name of the feature gate to be more clear:
s/VolumeDataSource/VolumePVCDataSource/
This commit is contained in:
j-griffith
2019-04-22 16:22:19 -06:00
parent 123f1bac35
commit a66bb3c63d
5 changed files with 154 additions and 7 deletions

View File

@@ -55,11 +55,15 @@ func dataSourceInUse(oldPVCSpec *core.PersistentVolumeClaimSpec) bool {
func dataSourceIsEnabled(pvcSpec *core.PersistentVolumeClaimSpec) bool {
if pvcSpec.DataSource != nil {
if pvcSpec.DataSource.Kind == "PersistentVolumeClaim" && utilfeature.DefaultFeatureGate.Enabled(features.VolumeDataSource) {
if pvcSpec.DataSource.Kind == "PersistentVolumeClaim" &&
*pvcSpec.DataSource.APIGroup == "" &&
utilfeature.DefaultFeatureGate.Enabled(features.VolumePVCDataSource) {
return true
}
if pvcSpec.DataSource.Kind == "VolumeSnapshot" && utilfeature.DefaultFeatureGate.Enabled(features.VolumeSnapshotDataSource) {
if pvcSpec.DataSource.Kind == "VolumeSnapshot" &&
*pvcSpec.DataSource.APIGroup == "snapshot.storage.k8s.io" &&
utilfeature.DefaultFeatureGate.Enabled(features.VolumeSnapshotDataSource) {
return true
}