@@ -10,6 +10,8 @@ import (
1010func Test_Merge (t * testing.T ) {
1111 internalScheme := elbv2gw .LoadBalancerSchemeInternal
1212 ipv4AddrType := elbv2gw .LoadBalancerIpAddressTypeIPv4
13+ mergeModeGWC := elbv2gw .MergeModePreferGatewayClass
14+ mergeModeGW := elbv2gw .MergeModePreferGateway
1315 testCases := []struct {
1416 name string
1517 gwClassLbConfig elbv2gw.LoadBalancerConfiguration
@@ -190,6 +192,329 @@ func Test_Merge(t *testing.T) {
190192 },
191193 },
192194 },
195+ {
196+ name : "full config in gw class and gw. merge mode prefers gatewayclass" ,
197+ gwClassLbConfig : elbv2gw.LoadBalancerConfiguration {
198+ Spec : elbv2gw.LoadBalancerConfigurationSpec {
199+ MergingMode : & mergeModeGWC ,
200+ LoadBalancerName : awssdk .String ("gwclass-name" ),
201+ Scheme : & internalScheme ,
202+ IpAddressType : & ipv4AddrType ,
203+ EnforceSecurityGroupInboundRulesOnPrivateLinkTraffic : awssdk .String ("off" ),
204+ CustomerOwnedIpv4Pool : awssdk .String ("coipv4-gwclass" ),
205+ IPv4IPAMPoolId : awssdk .String ("ipam pool gwclass" ),
206+ LoadBalancerSubnets : & []elbv2gw.SubnetConfiguration {
207+ {
208+ Identifier : "subnet-1a" ,
209+ },
210+ {
211+ Identifier : "subnet-1b" ,
212+ },
213+ },
214+ LoadBalancerSubnetsSelector : & map [string ][]string {
215+ "gwclass-v" : {"k1" , "k2" , "k3" },
216+ },
217+ SecurityGroups : & []string {"sg1" },
218+ SecurityGroupPrefixes : & []string {"pl1" },
219+ SourceRanges : & []string {"127.0.0.0/20" },
220+ VpcId : awssdk .String ("vpc-gw-class" ),
221+ ListenerConfigurations : & []elbv2gw.ListenerConfiguration {
222+ {
223+ ProtocolPort : "pp1-gwclass" ,
224+ DefaultCertificate : awssdk .String ("default-cert-gwclass" ),
225+ },
226+ {
227+ ProtocolPort : "pp1-common" ,
228+ DefaultCertificate : awssdk .String ("common-gwclass" ),
229+ },
230+ },
231+ LoadBalancerAttributes : []elbv2gw.LoadBalancerAttribute {
232+ {
233+ Key : "lb-gw-class-k-1" ,
234+ Value : "lb-gw-class-v-1" ,
235+ },
236+ {
237+ Key : "common" ,
238+ Value : "gwclass" ,
239+ },
240+ },
241+ Tags : & map [string ]string {
242+ "gwclass" : "key1" ,
243+ "commonTag" : "gwclass" ,
244+ },
245+ EnableICMP : awssdk .Bool (true ),
246+ ManageBackendSecurityGroupRules : awssdk .Bool (true ),
247+ },
248+ },
249+ gwLbConfig : elbv2gw.LoadBalancerConfiguration {
250+ Spec : elbv2gw.LoadBalancerConfigurationSpec {
251+ LoadBalancerName : awssdk .String ("gw-name" ),
252+ Scheme : & internalScheme ,
253+ IpAddressType : & ipv4AddrType ,
254+ EnforceSecurityGroupInboundRulesOnPrivateLinkTraffic : awssdk .String ("on" ),
255+ CustomerOwnedIpv4Pool : awssdk .String ("coipv4-class" ),
256+ IPv4IPAMPoolId : awssdk .String ("ipam pool class" ),
257+ LoadBalancerSubnets : & []elbv2gw.SubnetConfiguration {
258+ {
259+ Identifier : "subnet-1c" ,
260+ },
261+ },
262+ LoadBalancerSubnetsSelector : & map [string ][]string {
263+ "gw-v" : {"k1" , "k2" , "k3" },
264+ },
265+ SecurityGroups : & []string {"sg1-gw" },
266+ SecurityGroupPrefixes : & []string {"pl1-gw" },
267+ SourceRanges : & []string {"127.0.0.10/20" },
268+ VpcId : awssdk .String ("vpc-gw" ),
269+ ListenerConfigurations : & []elbv2gw.ListenerConfiguration {
270+ {
271+ ProtocolPort : "pp1-gw" ,
272+ DefaultCertificate : awssdk .String ("default-cert-gw" ),
273+ },
274+ {
275+ ProtocolPort : "pp1-common" ,
276+ DefaultCertificate : awssdk .String ("common-gw" ),
277+ },
278+ },
279+ LoadBalancerAttributes : []elbv2gw.LoadBalancerAttribute {
280+ {
281+ Key : "lb-gw-k-1" ,
282+ Value : "lb-gw-v-1" ,
283+ },
284+ {
285+ Key : "common" ,
286+ Value : "gw" ,
287+ },
288+ },
289+ Tags : & map [string ]string {
290+ "gw" : "key2" ,
291+ "commonTag" : "gw" ,
292+ },
293+ EnableICMP : awssdk .Bool (true ),
294+ ManageBackendSecurityGroupRules : awssdk .Bool (true ),
295+ },
296+ },
297+ expected : elbv2gw.LoadBalancerConfiguration {
298+ Spec : elbv2gw.LoadBalancerConfigurationSpec {
299+ LoadBalancerName : awssdk .String ("gwclass-name" ),
300+ Scheme : & internalScheme ,
301+ IpAddressType : & ipv4AddrType ,
302+ EnforceSecurityGroupInboundRulesOnPrivateLinkTraffic : awssdk .String ("off" ),
303+ CustomerOwnedIpv4Pool : awssdk .String ("coipv4-gwclass" ),
304+ IPv4IPAMPoolId : awssdk .String ("ipam pool gwclass" ),
305+ LoadBalancerSubnets : & []elbv2gw.SubnetConfiguration {
306+ {
307+ Identifier : "subnet-1a" ,
308+ },
309+ {
310+ Identifier : "subnet-1b" ,
311+ },
312+ },
313+ LoadBalancerSubnetsSelector : & map [string ][]string {
314+ "gwclass-v" : {"k1" , "k2" , "k3" },
315+ },
316+ SecurityGroups : & []string {"sg1" },
317+ SecurityGroupPrefixes : & []string {"pl1" },
318+ SourceRanges : & []string {"127.0.0.0/20" },
319+ VpcId : awssdk .String ("vpc-gw-class" ),
320+ ListenerConfigurations : & []elbv2gw.ListenerConfiguration {
321+ {
322+ ProtocolPort : "pp1-common" ,
323+ DefaultCertificate : awssdk .String ("common-gwclass" ),
324+ },
325+ {
326+ ProtocolPort : "pp1-gw" ,
327+ DefaultCertificate : awssdk .String ("default-cert-gw" ),
328+ },
329+ {
330+ ProtocolPort : "pp1-gwclass" ,
331+ DefaultCertificate : awssdk .String ("default-cert-gwclass" ),
332+ },
333+ },
334+ LoadBalancerAttributes : []elbv2gw.LoadBalancerAttribute {
335+ {
336+ Key : "common" ,
337+ Value : "gwclass" ,
338+ },
339+ {
340+ Key : "lb-gw-class-k-1" ,
341+ Value : "lb-gw-class-v-1" ,
342+ },
343+ {
344+ Key : "lb-gw-k-1" ,
345+ Value : "lb-gw-v-1" ,
346+ },
347+ },
348+ Tags : & map [string ]string {
349+ "gwclass" : "key1" ,
350+ "commonTag" : "gwclass" ,
351+ "gw" : "key2" ,
352+ },
353+ EnableICMP : awssdk .Bool (true ),
354+ ManageBackendSecurityGroupRules : awssdk .Bool (true ),
355+ },
356+ },
357+ },
358+ {
359+ name : "full config in gw class and gw. merge mode prefers gateway" ,
360+ gwClassLbConfig : elbv2gw.LoadBalancerConfiguration {
361+ Spec : elbv2gw.LoadBalancerConfigurationSpec {
362+ MergingMode : & mergeModeGW ,
363+ LoadBalancerName : awssdk .String ("gwclass-name" ),
364+ Scheme : & internalScheme ,
365+ IpAddressType : & ipv4AddrType ,
366+ EnforceSecurityGroupInboundRulesOnPrivateLinkTraffic : awssdk .String ("off" ),
367+ CustomerOwnedIpv4Pool : awssdk .String ("coipv4-gwclass" ),
368+ IPv4IPAMPoolId : awssdk .String ("ipam pool gwclass" ),
369+ LoadBalancerSubnets : & []elbv2gw.SubnetConfiguration {
370+ {
371+ Identifier : "subnet-1a" ,
372+ },
373+ {
374+ Identifier : "subnet-1b" ,
375+ },
376+ },
377+ LoadBalancerSubnetsSelector : & map [string ][]string {
378+ "gwclass-v" : {"k1" , "k2" , "k3" },
379+ },
380+ SecurityGroups : & []string {"sg1" },
381+ SecurityGroupPrefixes : & []string {"pl1" },
382+ SourceRanges : & []string {"127.0.0.0/20" },
383+ VpcId : awssdk .String ("vpc-gw-class" ),
384+ ListenerConfigurations : & []elbv2gw.ListenerConfiguration {
385+ {
386+ ProtocolPort : "pp1-gwclass" ,
387+ DefaultCertificate : awssdk .String ("default-cert-gwclass" ),
388+ },
389+ {
390+ ProtocolPort : "pp1-common" ,
391+ DefaultCertificate : awssdk .String ("common-gwclass" ),
392+ },
393+ },
394+ LoadBalancerAttributes : []elbv2gw.LoadBalancerAttribute {
395+ {
396+ Key : "lb-gw-class-k-1" ,
397+ Value : "lb-gw-class-v-1" ,
398+ },
399+ {
400+ Key : "common" ,
401+ Value : "gwclass" ,
402+ },
403+ },
404+ Tags : & map [string ]string {
405+ "gwclass" : "key1" ,
406+ "commonTag" : "gwclass" ,
407+ },
408+ EnableICMP : awssdk .Bool (true ),
409+ ManageBackendSecurityGroupRules : awssdk .Bool (true ),
410+ },
411+ },
412+ gwLbConfig : elbv2gw.LoadBalancerConfiguration {
413+ Spec : elbv2gw.LoadBalancerConfigurationSpec {
414+ LoadBalancerName : awssdk .String ("gw-name" ),
415+ Scheme : & internalScheme ,
416+ IpAddressType : & ipv4AddrType ,
417+ EnforceSecurityGroupInboundRulesOnPrivateLinkTraffic : awssdk .String ("on" ),
418+ CustomerOwnedIpv4Pool : awssdk .String ("coipv4-class" ),
419+ IPv4IPAMPoolId : awssdk .String ("ipam pool class" ),
420+ LoadBalancerSubnets : & []elbv2gw.SubnetConfiguration {
421+ {
422+ Identifier : "subnet-1c" ,
423+ },
424+ },
425+ LoadBalancerSubnetsSelector : & map [string ][]string {
426+ "gw-v" : {"k1" , "k2" , "k3" },
427+ },
428+ SecurityGroups : & []string {"sg1-gw" },
429+ SecurityGroupPrefixes : & []string {"pl1-gw" },
430+ SourceRanges : & []string {"127.0.0.10/20" },
431+ VpcId : awssdk .String ("vpc-gw" ),
432+ ListenerConfigurations : & []elbv2gw.ListenerConfiguration {
433+ {
434+ ProtocolPort : "pp1-gw" ,
435+ DefaultCertificate : awssdk .String ("default-cert-gw" ),
436+ },
437+ {
438+ ProtocolPort : "pp1-common" ,
439+ DefaultCertificate : awssdk .String ("common-gw" ),
440+ },
441+ },
442+ LoadBalancerAttributes : []elbv2gw.LoadBalancerAttribute {
443+ {
444+ Key : "lb-gw-k-1" ,
445+ Value : "lb-gw-v-1" ,
446+ },
447+ {
448+ Key : "common" ,
449+ Value : "gw" ,
450+ },
451+ },
452+ Tags : & map [string ]string {
453+ "gw" : "key2" ,
454+ "commonTag" : "gw" ,
455+ },
456+ EnableICMP : awssdk .Bool (true ),
457+ ManageBackendSecurityGroupRules : awssdk .Bool (true ),
458+ },
459+ },
460+ expected : elbv2gw.LoadBalancerConfiguration {
461+ Spec : elbv2gw.LoadBalancerConfigurationSpec {
462+ LoadBalancerName : awssdk .String ("gw-name" ),
463+ Scheme : & internalScheme ,
464+ IpAddressType : & ipv4AddrType ,
465+ EnforceSecurityGroupInboundRulesOnPrivateLinkTraffic : awssdk .String ("on" ),
466+ CustomerOwnedIpv4Pool : awssdk .String ("coipv4-class" ),
467+ IPv4IPAMPoolId : awssdk .String ("ipam pool class" ),
468+ LoadBalancerSubnets : & []elbv2gw.SubnetConfiguration {
469+ {
470+ Identifier : "subnet-1c" ,
471+ },
472+ },
473+ LoadBalancerSubnetsSelector : & map [string ][]string {
474+ "gw-v" : {"k1" , "k2" , "k3" },
475+ },
476+ SecurityGroups : & []string {"sg1-gw" },
477+ SecurityGroupPrefixes : & []string {"pl1-gw" },
478+ SourceRanges : & []string {"127.0.0.10/20" },
479+ VpcId : awssdk .String ("vpc-gw" ),
480+ ListenerConfigurations : & []elbv2gw.ListenerConfiguration {
481+ {
482+ ProtocolPort : "pp1-common" ,
483+ DefaultCertificate : awssdk .String ("common-gw" ),
484+ },
485+ {
486+ ProtocolPort : "pp1-gw" ,
487+ DefaultCertificate : awssdk .String ("default-cert-gw" ),
488+ },
489+ {
490+ ProtocolPort : "pp1-gwclass" ,
491+ DefaultCertificate : awssdk .String ("default-cert-gwclass" ),
492+ },
493+ },
494+ LoadBalancerAttributes : []elbv2gw.LoadBalancerAttribute {
495+ {
496+ Key : "common" ,
497+ Value : "gw" ,
498+ },
499+ {
500+ Key : "lb-gw-class-k-1" ,
501+ Value : "lb-gw-class-v-1" ,
502+ },
503+ {
504+ Key : "lb-gw-k-1" ,
505+ Value : "lb-gw-v-1" ,
506+ },
507+ },
508+ Tags : & map [string ]string {
509+ "gw" : "key2" ,
510+ "commonTag" : "gw" ,
511+ "gwclass" : "key1" ,
512+ },
513+ EnableICMP : awssdk .Bool (true ),
514+ ManageBackendSecurityGroupRules : awssdk .Bool (true ),
515+ },
516+ },
517+ },
193518 }
194519
195520 for _ , tc := range testCases {
0 commit comments