@@ -48,17 +48,17 @@ import (
48
48
)
49
49
50
50
func TestAddFlags (t * testing.T ) {
51
+ componentGlobalsRegistry := utilversion .DefaultComponentGlobalsRegistry
52
+ t .Cleanup (func () {
53
+ componentGlobalsRegistry .Reset ()
54
+ })
51
55
fs := pflag .NewFlagSet ("addflagstest" , pflag .PanicOnError )
52
56
53
- featureGate := featuregate .NewFeatureGate ()
54
- componentRegistry := utilversion .NewComponentGlobalsRegistry ()
55
- effectiveVersion := utilversion .NewEffectiveVersion ("1.32" )
56
- utilruntime .Must (componentRegistry .Register ("test" , effectiveVersion , featureGate ))
57
- s := NewServerRunOptions (featureGate , effectiveVersion )
57
+ utilruntime .Must (componentGlobalsRegistry .Register ("test" , utilversion .NewEffectiveVersion ("1.32" ), featuregate .NewFeatureGate ()))
58
+ s := NewServerRunOptions ()
58
59
for _ , f := range s .Flags ().FlagSets {
59
60
fs .AddFlagSet (f )
60
61
}
61
- componentRegistry .AddFlags (fs )
62
62
63
63
args := []string {
64
64
"--enable-admission-plugins=AlwaysDeny" ,
@@ -133,7 +133,7 @@ func TestAddFlags(t *testing.T) {
133
133
"--emulated-version=test=1.31" ,
134
134
}
135
135
fs .Parse (args )
136
- utilruntime .Must (componentRegistry .Set ())
136
+ utilruntime .Must (componentGlobalsRegistry .Set ())
137
137
138
138
// This is a snapshot of expected options parsed by args.
139
139
expected := & ServerRunOptions {
@@ -147,8 +147,8 @@ func TestAddFlags(t *testing.T) {
147
147
MinRequestTimeout : 1800 ,
148
148
JSONPatchMaxCopyBytes : int64 (3 * 1024 * 1024 ),
149
149
MaxRequestBodyBytes : int64 (3 * 1024 * 1024 ),
150
- FeatureGate : featureGate ,
151
- EffectiveVersion : effectiveVersion ,
150
+ ComponentGlobalsRegistry : componentGlobalsRegistry ,
151
+ ComponentName : utilversion . DefaultKubeComponent ,
152
152
},
153
153
Admission : & kubeoptions.AdmissionOptions {
154
154
GenericAdmission : & apiserveroptions.AdmissionOptions {
@@ -350,8 +350,8 @@ func TestAddFlags(t *testing.T) {
350
350
if ! reflect .DeepEqual (expected , s ) {
351
351
t .Errorf ("Got different run options than expected.\n Difference detected on:\n %s" , cmp .Diff (expected , s , cmpopts .IgnoreUnexported (admission.Plugins {}, kubeoptions.OIDCAuthenticationOptions {})))
352
352
}
353
-
354
- if s . GenericServerRunOptions . EffectiveVersion .EmulationVersion ().String () != "1.31" {
355
- t .Errorf ("Got emulation version %s, wanted %s" , s . GenericServerRunOptions . EffectiveVersion .EmulationVersion ().String (), "1.31" )
353
+ testEffectiveVersion := s . GenericServerRunOptions . ComponentGlobalsRegistry . EffectiveVersionFor ( "test" )
354
+ if testEffectiveVersion .EmulationVersion ().String () != "1.31" {
355
+ t .Errorf ("Got emulation version %s, wanted %s" , testEffectiveVersion .EmulationVersion ().String (), "1.31" )
356
356
}
357
357
}
0 commit comments