@@ -3489,6 +3489,74 @@ func Test_getLoadBalancerTags(t *testing.T) {
3489
3489
},
3490
3490
err : nil ,
3491
3491
},
3492
+ "reverse compatibility tags test for nlb 1" : {
3493
+ service : & v1.Service {
3494
+ ObjectMeta : metav1.ObjectMeta {
3495
+ Annotations : map [string ]string {
3496
+ ServiceAnnotationLoadBalancerType : "nlb" ,
3497
+ ServiceAnnotationNetworkLoadBalancerFreeformTags : `{"cluster":"resource1", "unique":"tag1"}` ,
3498
+ ServiceAnnotationNetworkLoadBalancerDefinedTags : `{"namespace":{"key":"value1", "owner":"team1"}}` ,
3499
+ ServiceAnnotationNetworkLoadBalancerInitialFreeformTagsOverride : `{"cluster":"resource", "unique":"tag"}` ,
3500
+ ServiceAnnotationNetworkLoadBalancerInitialDefinedTagsOverride : `{"namespace":{"key":"value", "owner":"team"}}` ,
3501
+ },
3502
+ },
3503
+ },
3504
+ desiredLBTags : & providercfg.TagConfig {
3505
+ FreeformTags : map [string ]string {"cluster" : "resource" , "unique" : "tag" },
3506
+ DefinedTags : map [string ]map [string ]interface {}{"namespace" : {"owner" : "team" , "key" : "value" }},
3507
+ },
3508
+ err : nil ,
3509
+ },
3510
+ "reverse compatibility tags test for nlb 2" : {
3511
+ service : & v1.Service {
3512
+ ObjectMeta : metav1.ObjectMeta {
3513
+ Annotations : map [string ]string {
3514
+ ServiceAnnotationLoadBalancerType : "nlb" ,
3515
+ ServiceAnnotationNetworkLoadBalancerFreeformTags : `{"cluster":"resource1", "unique":"tag1"}` ,
3516
+ ServiceAnnotationNetworkLoadBalancerDefinedTags : `{"namespace":{"key":"value1", "owner":"team1"}}` ,
3517
+ },
3518
+ },
3519
+ },
3520
+ desiredLBTags : & providercfg.TagConfig {
3521
+ FreeformTags : map [string ]string {"cluster" : "resource1" , "unique" : "tag1" },
3522
+ DefinedTags : map [string ]map [string ]interface {}{"namespace" : {"owner" : "team1" , "key" : "value1" }},
3523
+ },
3524
+ err : nil ,
3525
+ },
3526
+ "reverse compatibility tags test for nlb 3" : {
3527
+ service : & v1.Service {
3528
+ ObjectMeta : metav1.ObjectMeta {
3529
+ Annotations : map [string ]string {
3530
+ ServiceAnnotationLoadBalancerType : "nlb" ,
3531
+ ServiceAnnotationNetworkLoadBalancerFreeformTags : `{"cluster":"resource1", "unique":"tag1"}` ,
3532
+ ServiceAnnotationNetworkLoadBalancerDefinedTags : `{"namespace":{"key":"value1", "owner":"team1"}}` ,
3533
+ ServiceAnnotationNetworkLoadBalancerInitialDefinedTagsOverride : `{"namespace":{"key":"value", "owner":"team"}}` ,
3534
+ },
3535
+ },
3536
+ },
3537
+ desiredLBTags : & providercfg.TagConfig {
3538
+ FreeformTags : map [string ]string {"cluster" : "resource1" , "unique" : "tag1" },
3539
+ DefinedTags : map [string ]map [string ]interface {}{"namespace" : {"owner" : "team" , "key" : "value" }},
3540
+ },
3541
+ err : nil ,
3542
+ },
3543
+ "reverse compatibility tags test for nlb 4" : {
3544
+ service : & v1.Service {
3545
+ ObjectMeta : metav1.ObjectMeta {
3546
+ Annotations : map [string ]string {
3547
+ ServiceAnnotationLoadBalancerType : "nlb" ,
3548
+ ServiceAnnotationNetworkLoadBalancerFreeformTags : `{"cluster":"resource1", "unique":"tag1"}` ,
3549
+ ServiceAnnotationNetworkLoadBalancerDefinedTags : `{"namespace":{"key":"value1", "owner":"team1"}}` ,
3550
+ ServiceAnnotationNetworkLoadBalancerInitialFreeformTagsOverride : `{"cluster":"resource", "unique":"tag"}` ,
3551
+ },
3552
+ },
3553
+ },
3554
+ desiredLBTags : & providercfg.TagConfig {
3555
+ FreeformTags : map [string ]string {"cluster" : "resource" , "unique" : "tag" },
3556
+ DefinedTags : map [string ]map [string ]interface {}{"namespace" : {"owner" : "team1" , "key" : "value1" }},
3557
+ },
3558
+ err : nil ,
3559
+ },
3492
3560
}
3493
3561
3494
3562
for name , tc := range testCases {
@@ -3599,7 +3667,7 @@ func Test_getHealthChecker(t *testing.T) {
3599
3667
},
3600
3668
},
3601
3669
expected : nil ,
3602
- err : fmt .Errorf ("invalid value for health check interval, should be between %v and %v" , LBHealthCheckIntervalMin , LBHealthCheckIntervalMax ),
3670
+ err : fmt .Errorf ("invalid value for health check interval, should be between %v and %v" , LBHealthCheckIntervalMin , LBHealthCheckIntervalMax ),
3603
3671
},
3604
3672
"lb wrong interval value - greater than max" : {
3605
3673
service : & v1.Service {
@@ -3610,31 +3678,31 @@ func Test_getHealthChecker(t *testing.T) {
3610
3678
},
3611
3679
},
3612
3680
expected : nil ,
3613
- err : fmt .Errorf ("invalid value for health check interval, should be between %v and %v" , LBHealthCheckIntervalMin , LBHealthCheckIntervalMax ),
3681
+ err : fmt .Errorf ("invalid value for health check interval, should be between %v and %v" , LBHealthCheckIntervalMin , LBHealthCheckIntervalMax ),
3614
3682
},
3615
3683
"nlb wrong interval value - lesser than min" : {
3616
3684
service : & v1.Service {
3617
3685
ObjectMeta : metav1.ObjectMeta {
3618
3686
Annotations : map [string ]string {
3619
- ServiceAnnotationLoadBalancerType : "nlb" ,
3687
+ ServiceAnnotationLoadBalancerType : "nlb" ,
3620
3688
ServiceAnnotationNetworkLoadBalancerHealthCheckInterval : "3000" ,
3621
3689
},
3622
3690
},
3623
3691
},
3624
3692
expected : nil ,
3625
- err : fmt .Errorf ("invalid value for health check interval, should be between %v and %v" , NLBHealthCheckIntervalMin , NLBHealthCheckIntervalMax ),
3693
+ err : fmt .Errorf ("invalid value for health check interval, should be between %v and %v" , NLBHealthCheckIntervalMin , NLBHealthCheckIntervalMax ),
3626
3694
},
3627
3695
"nlb wrong interval value - greater than max" : {
3628
3696
service : & v1.Service {
3629
3697
ObjectMeta : metav1.ObjectMeta {
3630
3698
Annotations : map [string ]string {
3631
- ServiceAnnotationLoadBalancerType : "nlb" ,
3699
+ ServiceAnnotationLoadBalancerType : "nlb" ,
3632
3700
ServiceAnnotationNetworkLoadBalancerHealthCheckInterval : "3000000" ,
3633
3701
},
3634
3702
},
3635
3703
},
3636
3704
expected : nil ,
3637
- err : fmt .Errorf ("invalid value for health check interval, should be between %v and %v" , NLBHealthCheckIntervalMin , NLBHealthCheckIntervalMax ),
3705
+ err : fmt .Errorf ("invalid value for health check interval, should be between %v and %v" , NLBHealthCheckIntervalMin , NLBHealthCheckIntervalMax ),
3638
3706
},
3639
3707
}
3640
3708
@@ -3825,10 +3893,10 @@ func Test_getSecurityListManagementMode(t *testing.T) {
3825
3893
}
3826
3894
}
3827
3895
3828
- func Test_validateService (t * testing.T ){
3896
+ func Test_validateService (t * testing.T ) {
3829
3897
testCases := map [string ]struct {
3830
- service * v1.Service
3831
- err error
3898
+ service * v1.Service
3899
+ err error
3832
3900
}{
3833
3901
"defaults" : {
3834
3902
service : & v1.Service {
@@ -3848,7 +3916,7 @@ func Test_validateService(t *testing.T){
3848
3916
},
3849
3917
ObjectMeta : metav1.ObjectMeta {
3850
3918
Annotations : map [string ]string {
3851
- ServiceAnnotationLoadBalancerType : "nlb" ,
3919
+ ServiceAnnotationLoadBalancerType : "nlb" ,
3852
3920
ServiceAnnotationNetworkLoadBalancerSecurityListManagementMode : "Neither" ,
3853
3921
},
3854
3922
},
@@ -3885,7 +3953,7 @@ func Test_validateService(t *testing.T){
3885
3953
},
3886
3954
ObjectMeta : metav1.ObjectMeta {
3887
3955
Annotations : map [string ]string {
3888
- ServiceAnnotationLoadBalancerType : "nlb" ,
3956
+ ServiceAnnotationLoadBalancerType : "nlb" ,
3889
3957
ServiceAnnotationNetworkLoadBalancerSecurityListManagementMode : "All" ,
3890
3958
},
3891
3959
},
@@ -3905,7 +3973,7 @@ func Test_validateService(t *testing.T){
3905
3973
},
3906
3974
ObjectMeta : metav1.ObjectMeta {
3907
3975
Annotations : map [string ]string {
3908
- ServiceAnnotationLoadBalancerType : "nlb" ,
3976
+ ServiceAnnotationLoadBalancerType : "nlb" ,
3909
3977
ServiceAnnotationNetworkLoadBalancerSecurityListManagementMode : "None" ,
3910
3978
},
3911
3979
},
0 commit comments