@@ -208,14 +208,8 @@ func testWorkloadDefaults(t *testing.T, featuresEnabled bool) {
208
208
".Spec.HostNetwork" : "true" ,
209
209
".Spec.Containers[0].Ports[0].ContainerPort" : "12345" ,
210
210
}
211
- if utilfeature .DefaultFeatureGate .Enabled (features .DefaultHostNetworkHostPortsInPodTemplates ) {
212
- m [".Spec.Containers" ] = `[{"name":"","ports":[{"hostPort":12345,"containerPort":12345,"protocol":"TCP"}],"resources":{},"terminationMessagePath":"/dev/termination-log","terminationMessagePolicy":"File","imagePullPolicy":"IfNotPresent"}]`
213
- m [".Spec.Containers[0].Ports" ] = `[{"hostPort":12345,"containerPort":12345,"protocol":"TCP"}]`
214
- m [".Spec.Containers[0].Ports[0].HostPort" ] = "12345"
215
- } else {
216
- m [".Spec.Containers" ] = `[{"name":"","ports":[{"containerPort":12345,"protocol":"TCP"}],"resources":{},"terminationMessagePath":"/dev/termination-log","terminationMessagePolicy":"File","imagePullPolicy":"IfNotPresent"}]`
217
- m [".Spec.Containers[0].Ports" ] = `[{"containerPort":12345,"protocol":"TCP"}]`
218
- }
211
+ m [".Spec.Containers" ] = `[{"name":"","ports":[{"containerPort":12345,"protocol":"TCP"}],"resources":{},"terminationMessagePath":"/dev/termination-log","terminationMessagePolicy":"File","imagePullPolicy":"IfNotPresent"}]`
212
+ m [".Spec.Containers[0].Ports" ] = `[{"containerPort":12345,"protocol":"TCP"}]`
219
213
for k , v := range expectedDefaults {
220
214
if _ , found := m [k ]; ! found {
221
215
m [k ] = v
@@ -379,40 +373,23 @@ func testPodDefaults(t *testing.T, featuresEnabled bool) {
379
373
func TestPodHostNetworkDefaults (t * testing.T ) {
380
374
cases := []struct {
381
375
name string
382
- gate bool
383
376
hostNet bool
384
377
expectPodDefault bool
385
378
expectPodSpecDefault bool
386
379
}{{
387
- name : "gate disabled, hostNetwork=false" ,
388
- gate : false ,
380
+ name : "hostNetwork=false" ,
389
381
hostNet : false ,
390
382
expectPodDefault : false ,
391
383
expectPodSpecDefault : false ,
392
384
}, {
393
- name : "gate disabled, hostNetwork=true" ,
394
- gate : false ,
385
+ name : "hostNetwork=true" ,
395
386
hostNet : true ,
396
387
expectPodDefault : true ,
397
388
expectPodSpecDefault : false ,
398
- }, {
399
- name : "gate enabled, hostNetwork=false" ,
400
- gate : true ,
401
- hostNet : false ,
402
- expectPodDefault : false ,
403
- expectPodSpecDefault : false ,
404
- }, {
405
- name : "gate enabled, hostNetwork=true" ,
406
- gate : true ,
407
- hostNet : true ,
408
- expectPodDefault : true ,
409
- expectPodSpecDefault : true ,
410
389
}}
411
390
412
391
for _ , tc := range cases {
413
392
t .Run (tc .name , func (t * testing.T ) {
414
- defer featuregatetesting .SetFeatureGateDuringTest (t , utilfeature .DefaultFeatureGate , features .DefaultHostNetworkHostPortsInPodTemplates , tc .gate )()
415
-
416
393
const portNum = 12345
417
394
spec := v1.PodSpec {
418
395
HostNetwork : tc .hostNet ,
0 commit comments