@@ -216,7 +216,7 @@ func Test_buildFrontendNlbSubnetMappings(t *testing.T) {
216
216
},
217
217
},
218
218
{
219
- name : "with subnets annoattion " ,
219
+ name : "with subnets annotation " ,
220
220
fields : fields {
221
221
ingGroup : Group {
222
222
ID : GroupID {
@@ -302,6 +302,34 @@ func Test_buildFrontendNlbSubnetMappings(t *testing.T) {
302
302
wantMappings : nil ,
303
303
wantErr : "count of EIP allocations (2) and subnets (1) must match" ,
304
304
},
305
+ {
306
+ name : "error when EIP allocations are specified but scheme is internal" ,
307
+ fields : fields {
308
+ ingGroup : Group {
309
+ ID : GroupID {
310
+ Namespace : "awesome-ns" ,
311
+ Name : "my-ingress" ,
312
+ },
313
+ Members : []ClassifiedIngress {
314
+ {
315
+ Ing : & networking.Ingress {
316
+ ObjectMeta : metav1.ObjectMeta {
317
+ Namespace : "awesome-ns" ,
318
+ Name : "ing-5" ,
319
+ Annotations : map [string ]string {
320
+ "alb.ingress.kubernetes.io/frontend-nlb-subnets" : "subnet-1,subnet-2" ,
321
+ "alb.ingress.kubernetes.io/frontend-nlb-eip-allocations" : "eip-1,eip-2" ,
322
+ },
323
+ },
324
+ },
325
+ },
326
+ },
327
+ },
328
+ scheme : elbv2 .LoadBalancerSchemeInternal , // EIPs not allowed for internal scheme
329
+ },
330
+ wantMappings : nil ,
331
+ wantErr : "EIP allocations can only be set for internet facing load balancers" ,
332
+ },
305
333
}
306
334
for _ , tt := range tests {
307
335
t .Run (tt .name , func (t * testing.T ) {
@@ -340,7 +368,12 @@ func Test_buildFrontendNlbSubnetMappings(t *testing.T) {
340
368
annotationParser : annotationParser ,
341
369
subnetsResolver : subnetsResolver ,
342
370
}
343
- got , err := task .buildFrontendNlbSubnetMappings (context .Background (), tt .fields .scheme )
371
+ alb := & elbv2model.LoadBalancer {
372
+ Spec : elbv2model.LoadBalancerSpec {
373
+ Scheme : tt .fields .scheme ,
374
+ },
375
+ }
376
+ got , err := task .buildFrontendNlbSubnetMappings (context .Background (), tt .fields .scheme , alb )
344
377
345
378
if err != nil {
346
379
assert .EqualError (t , err , tt .wantErr )
0 commit comments