@@ -49,12 +49,7 @@ func TestWorkloadDefaults(t *testing.T) {
4949 t .Run ("disabled_features" , func (t * testing.T ) { testWorkloadDefaults (t , false ) })
5050}
5151func testWorkloadDefaults (t * testing.T , featuresEnabled bool ) {
52- allFeatures := utilfeature .DefaultFeatureGate .DeepCopy ().GetAll ()
53- for feature , featureSpec := range allFeatures {
54- if ! featureSpec .LockToDefault {
55- featuregatetesting .SetFeatureGateDuringTest (t , utilfeature .DefaultFeatureGate , feature , featuresEnabled )
56- }
57- }
52+ setAllFeatures (t , featuresEnabled )
5853 // New defaults under PodTemplateSpec are only acceptable if they would not be applied when reading data from a previous release.
5954 // Forbidden: adding a new field `MyField *bool` and defaulting it to a non-nil value
6055 // Forbidden: defaulting an existing field `MyField *bool` when it was previously not defaulted
@@ -240,12 +235,7 @@ func TestPodDefaults(t *testing.T) {
240235 t .Run ("disabled_features" , func (t * testing.T ) { testPodDefaults (t , false ) })
241236}
242237func testPodDefaults (t * testing.T , featuresEnabled bool ) {
243- features := utilfeature .DefaultFeatureGate .DeepCopy ().GetAll ()
244- for feature , featureSpec := range features {
245- if ! featureSpec .LockToDefault {
246- featuregatetesting .SetFeatureGateDuringTest (t , utilfeature .DefaultFeatureGate , feature , featuresEnabled )
247- }
248- }
238+ setAllFeatures (t , featuresEnabled )
249239 pod := & v1.Pod {}
250240 // New defaults under PodSpec are only acceptable if they would not be applied when reading data from a previous release.
251241 // Forbidden: adding a new field `MyField *bool` and defaulting it to a non-nil value
@@ -3395,3 +3385,13 @@ func TestSetDefaults_PodLogOptions(t *testing.T) {
33953385 })
33963386 }
33973387}
3388+
3389+ func setAllFeatures (t * testing.T , featuresEnabled bool ) {
3390+ features := featuregatetesting.FeatureOverrides {}
3391+ for feature , featureSpec := range utilfeature .DefaultFeatureGate .DeepCopy ().GetAll () {
3392+ if ! featureSpec .LockToDefault {
3393+ features [feature ] = featuresEnabled
3394+ }
3395+ }
3396+ featuregatetesting .SetFeatureGatesDuringTest (t , utilfeature .DefaultFeatureGate , features )
3397+ }
0 commit comments