mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
Make matchConditionsFeatureGateInitiallyEnabled a boolean instead
This commit is contained in:
parent
6b3ce3004d
commit
00de051729
@ -730,20 +730,20 @@ func TestMatchConditions_validation(t *testing.T) {
|
||||
func TestFeatureGateEnablement(t *testing.T) {
|
||||
testcases := []struct {
|
||||
name string
|
||||
matchConditionsFeatureGateInitiaState string
|
||||
matchConditionsFeatureGateInitiallyEnabled bool
|
||||
matchConditions []admissionregistrationv1.MatchCondition
|
||||
expectMatchConditionsPreSwitch bool
|
||||
expectMatchConditionsPostSwitch bool
|
||||
}{
|
||||
{
|
||||
name: "start with match conditions enabled - no match conditions",
|
||||
matchConditionsFeatureGateInitiaState: "enabled",
|
||||
matchConditionsFeatureGateInitiallyEnabled: true,
|
||||
expectMatchConditionsPreSwitch: false,
|
||||
expectMatchConditionsPostSwitch: false,
|
||||
},
|
||||
{
|
||||
name: "start with match conditions enabled - with match conditions",
|
||||
matchConditionsFeatureGateInitiaState: "enabled",
|
||||
matchConditionsFeatureGateInitiallyEnabled: true,
|
||||
matchConditions: []admissionregistrationv1.MatchCondition{{
|
||||
Name: "test-expression",
|
||||
Expression: "true",
|
||||
@ -753,13 +753,13 @@ func TestFeatureGateEnablement(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "start with match conditions disabled - no match conditions",
|
||||
matchConditionsFeatureGateInitiaState: "disabled",
|
||||
matchConditionsFeatureGateInitiallyEnabled: false,
|
||||
expectMatchConditionsPreSwitch: false,
|
||||
expectMatchConditionsPostSwitch: false,
|
||||
},
|
||||
{
|
||||
name: "start with match conditions disabled - with match conditions",
|
||||
matchConditionsFeatureGateInitiaState: "disabled",
|
||||
matchConditionsFeatureGateInitiallyEnabled: false,
|
||||
matchConditions: []admissionregistrationv1.MatchCondition{{
|
||||
Name: "test-expression",
|
||||
Expression: "true",
|
||||
@ -794,7 +794,7 @@ func TestFeatureGateEnablement(t *testing.T) {
|
||||
|
||||
for _, testcase := range testcases {
|
||||
t.Run(testcase.name, func(t *testing.T) {
|
||||
if testcase.matchConditionsFeatureGateInitiaState == "enabled" {
|
||||
if testcase.matchConditionsFeatureGateInitiallyEnabled {
|
||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.AdmissionWebhookMatchConditions, true)()
|
||||
}
|
||||
|
||||
@ -887,7 +887,7 @@ func TestFeatureGateEnablement(t *testing.T) {
|
||||
}
|
||||
|
||||
// Switch the featureGate state
|
||||
if testcase.matchConditionsFeatureGateInitiaState == "enabled" {
|
||||
if testcase.matchConditionsFeatureGateInitiallyEnabled {
|
||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.AdmissionWebhookMatchConditions, false)()
|
||||
} else {
|
||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.AdmissionWebhookMatchConditions, true)()
|
||||
|
Loading…
Reference in New Issue
Block a user