@@ -15,6 +15,8 @@ import (
15
15
"k8s.io/client-go/kubernetes"
16
16
17
17
"github.com/linode/linode-cloud-controller-manager/cloud/linode/client/mocks"
18
+ "github.com/linode/linode-cloud-controller-manager/cloud/linode/options"
19
+ ccmUtils "github.com/linode/linode-cloud-controller-manager/cloud/linode/utils"
18
20
)
19
21
20
22
const (
32
34
Labels : map [string ]string {"cilium-bgp-peering" : "true" },
33
35
},
34
36
Spec : v1.NodeSpec {
35
- ProviderID : fmt .Sprintf ("%s%d" , providerIDPrefix , 11111 ),
37
+ ProviderID : fmt .Sprintf ("%s%d" , ccmUtils . ProviderIDPrefix , 11111 ),
36
38
},
37
39
},
38
40
{
@@ -41,15 +43,15 @@ var (
41
43
Labels : map [string ]string {"cilium-bgp-peering" : "true" },
42
44
},
43
45
Spec : v1.NodeSpec {
44
- ProviderID : fmt .Sprintf ("%s%d" , providerIDPrefix , 22222 ),
46
+ ProviderID : fmt .Sprintf ("%s%d" , ccmUtils . ProviderIDPrefix , 22222 ),
45
47
},
46
48
},
47
49
{
48
50
ObjectMeta : metav1.ObjectMeta {
49
51
Name : "node-3" ,
50
52
},
51
53
Spec : v1.NodeSpec {
52
- ProviderID : fmt .Sprintf ("%s%d" , providerIDPrefix , 33333 ),
54
+ ProviderID : fmt .Sprintf ("%s%d" , ccmUtils . ProviderIDPrefix , 33333 ),
53
55
},
54
56
},
55
57
{
60
62
},
61
63
},
62
64
Spec : v1.NodeSpec {
63
- ProviderID : fmt .Sprintf ("%s%d" , providerIDPrefix , 44444 ),
65
+ ProviderID : fmt .Sprintf ("%s%d" , ccmUtils . ProviderIDPrefix , 44444 ),
64
66
},
65
67
},
66
68
}
71
73
Labels : map [string ]string {"cilium-bgp-peering" : "true" },
72
74
},
73
75
Spec : v1.NodeSpec {
74
- ProviderID : fmt .Sprintf ("%s%d" , providerIDPrefix , 55555 ),
76
+ ProviderID : fmt .Sprintf ("%s%d" , ccmUtils . ProviderIDPrefix , 55555 ),
75
77
},
76
78
},
77
79
}
@@ -202,7 +204,7 @@ func addNodes(t *testing.T, kubeClient kubernetes.Interface, nodes []*v1.Node) {
202
204
func createNewIpHolderInstance () linodego.Instance {
203
205
return linodego.Instance {
204
206
ID : 123456 ,
205
- Label : generateClusterScopedIPHolderLinodeName (zone , Options .IpHolderSuffix ),
207
+ Label : generateClusterScopedIPHolderLinodeName (zone , options . Options .IpHolderSuffix ),
206
208
Type : "g6-standard-1" ,
207
209
Region : "us-west" ,
208
210
IPv4 : []* net.IP {& publicIPv4 },
@@ -212,8 +214,8 @@ func createNewIpHolderInstance() linodego.Instance {
212
214
func testNoBGPNodeLabel (t * testing.T , mc * mocks.MockClient ) {
213
215
t .Helper ()
214
216
215
- Options .BGPNodeSelector = ""
216
- Options .IpHolderSuffix = clusterName
217
+ options . Options .BGPNodeSelector = ""
218
+ options . Options .IpHolderSuffix = clusterName
217
219
t .Setenv ("BGP_PEER_PREFIX" , "2600:3cef" )
218
220
svc := createTestService ()
219
221
newIpHolderInstance = createNewIpHolderInstance ()
@@ -231,7 +233,7 @@ func testNoBGPNodeLabel(t *testing.T, mc *mocks.MockClient) {
231
233
}
232
234
233
235
mc .EXPECT ().ListInstances (gomock .Any (), linodego .NewListOptions (1 , string (rawFilter ))).Times (1 ).Return ([]linodego.Instance {}, nil )
234
- filter = map [string ]string {"label" : generateClusterScopedIPHolderLinodeName (zone , Options .IpHolderSuffix )}
236
+ filter = map [string ]string {"label" : generateClusterScopedIPHolderLinodeName (zone , options . Options .IpHolderSuffix )}
235
237
rawFilter , err = json .Marshal (filter )
236
238
if err != nil {
237
239
t .Errorf ("json marshal error: %v" , err )
@@ -271,7 +273,7 @@ func testNoBGPNodeLabel(t *testing.T, mc *mocks.MockClient) {
271
273
func testUnsupportedRegion (t * testing.T , mc * mocks.MockClient ) {
272
274
t .Helper ()
273
275
274
- Options .BGPNodeSelector = nodeSelector
276
+ options . Options .BGPNodeSelector = nodeSelector
275
277
svc := createTestService ()
276
278
277
279
kubeClient , _ := k8sClient .NewFakeClientset ()
@@ -302,7 +304,7 @@ func testUnsupportedRegion(t *testing.T, mc *mocks.MockClient) {
302
304
func testCreateWithExistingIPHolderWithOldIpHolderNamingConvention (t * testing.T , mc * mocks.MockClient ) {
303
305
t .Helper ()
304
306
305
- Options .BGPNodeSelector = nodeSelector
307
+ options . Options .BGPNodeSelector = nodeSelector
306
308
svc := createTestService ()
307
309
newIpHolderInstance = createNewIpHolderInstance ()
308
310
@@ -346,8 +348,8 @@ func testCreateWithExistingIPHolderWithOldIpHolderNamingConvention(t *testing.T,
346
348
func testCreateWithExistingIPHolderWithNewIpHolderNamingConvention (t * testing.T , mc * mocks.MockClient ) {
347
349
t .Helper ()
348
350
349
- Options .BGPNodeSelector = nodeSelector
350
- Options .IpHolderSuffix = clusterName
351
+ options . Options .BGPNodeSelector = nodeSelector
352
+ options . Options .IpHolderSuffix = clusterName
351
353
svc := createTestService ()
352
354
newIpHolderInstance = createNewIpHolderInstance ()
353
355
@@ -391,8 +393,8 @@ func testCreateWithExistingIPHolderWithNewIpHolderNamingConvention(t *testing.T,
391
393
func testCreateWithExistingIPHolderWithNewIpHolderNamingConventionUsingLongSuffix (t * testing.T , mc * mocks.MockClient ) {
392
394
t .Helper ()
393
395
394
- Options .BGPNodeSelector = nodeSelector
395
- Options .IpHolderSuffix = "OaTJrRuufacHVougjwkpBpmstiqvswvBNEMWXsRYfMBTCkKIUTXpbGIcIbDWSQp"
396
+ options . Options .BGPNodeSelector = nodeSelector
397
+ options . Options .IpHolderSuffix = "OaTJrRuufacHVougjwkpBpmstiqvswvBNEMWXsRYfMBTCkKIUTXpbGIcIbDWSQp"
396
398
svc := createTestService ()
397
399
newIpHolderInstance = createNewIpHolderInstance ()
398
400
@@ -436,8 +438,8 @@ func testCreateWithExistingIPHolderWithNewIpHolderNamingConventionUsingLongSuffi
436
438
func testCreateWithNoExistingIPHolderUsingNoSuffix (t * testing.T , mc * mocks.MockClient ) {
437
439
t .Helper ()
438
440
439
- Options .BGPNodeSelector = nodeSelector
440
- Options .IpHolderSuffix = ""
441
+ options . Options .BGPNodeSelector = nodeSelector
442
+ options . Options .IpHolderSuffix = ""
441
443
svc := createTestService ()
442
444
newIpHolderInstance = createNewIpHolderInstance ()
443
445
@@ -453,7 +455,7 @@ func testCreateWithNoExistingIPHolderUsingNoSuffix(t *testing.T, mc *mocks.MockC
453
455
t .Errorf ("json marshal error: %v" , err )
454
456
}
455
457
mc .EXPECT ().ListInstances (gomock .Any (), linodego .NewListOptions (1 , string (rawFilter ))).Times (1 ).Return ([]linodego.Instance {}, nil )
456
- filter = map [string ]string {"label" : generateClusterScopedIPHolderLinodeName (zone , Options .IpHolderSuffix )}
458
+ filter = map [string ]string {"label" : generateClusterScopedIPHolderLinodeName (zone , options . Options .IpHolderSuffix )}
457
459
rawFilter , err = json .Marshal (filter )
458
460
if err != nil {
459
461
t .Errorf ("json marshal error: %v" , err )
@@ -488,8 +490,8 @@ func testCreateWithNoExistingIPHolderUsingNoSuffix(t *testing.T, mc *mocks.MockC
488
490
func testCreateWithNoExistingIPHolderUsingShortSuffix (t * testing.T , mc * mocks.MockClient ) {
489
491
t .Helper ()
490
492
491
- Options .BGPNodeSelector = nodeSelector
492
- Options .IpHolderSuffix = clusterName
493
+ options . Options .BGPNodeSelector = nodeSelector
494
+ options . Options .IpHolderSuffix = clusterName
493
495
svc := createTestService ()
494
496
newIpHolderInstance = createNewIpHolderInstance ()
495
497
@@ -505,7 +507,7 @@ func testCreateWithNoExistingIPHolderUsingShortSuffix(t *testing.T, mc *mocks.Mo
505
507
t .Errorf ("json marshal error: %v" , err )
506
508
}
507
509
mc .EXPECT ().ListInstances (gomock .Any (), linodego .NewListOptions (1 , string (rawFilter ))).Times (1 ).Return ([]linodego.Instance {}, nil )
508
- filter = map [string ]string {"label" : generateClusterScopedIPHolderLinodeName (zone , Options .IpHolderSuffix )}
510
+ filter = map [string ]string {"label" : generateClusterScopedIPHolderLinodeName (zone , options . Options .IpHolderSuffix )}
509
511
rawFilter , err = json .Marshal (filter )
510
512
if err != nil {
511
513
t .Errorf ("json marshal error: %v" , err )
@@ -540,8 +542,8 @@ func testCreateWithNoExistingIPHolderUsingShortSuffix(t *testing.T, mc *mocks.Mo
540
542
func testCreateWithNoExistingIPHolderUsingLongSuffix (t * testing.T , mc * mocks.MockClient ) {
541
543
t .Helper ()
542
544
543
- Options .BGPNodeSelector = nodeSelector
544
- Options .IpHolderSuffix = "OaTJrRuufacHVougjwkpBpmstiqvswvBNEMWXsRYfMBTCkKIUTXpbGIcIbDWSQp"
545
+ options . Options .BGPNodeSelector = nodeSelector
546
+ options . Options .IpHolderSuffix = "OaTJrRuufacHVougjwkpBpmstiqvswvBNEMWXsRYfMBTCkKIUTXpbGIcIbDWSQp"
545
547
svc := createTestService ()
546
548
newIpHolderInstance = createNewIpHolderInstance ()
547
549
@@ -557,7 +559,7 @@ func testCreateWithNoExistingIPHolderUsingLongSuffix(t *testing.T, mc *mocks.Moc
557
559
t .Errorf ("json marshal error: %v" , err )
558
560
}
559
561
mc .EXPECT ().ListInstances (gomock .Any (), linodego .NewListOptions (1 , string (rawFilter ))).Times (1 ).Return ([]linodego.Instance {}, nil )
560
- filter = map [string ]string {"label" : generateClusterScopedIPHolderLinodeName (zone , Options .IpHolderSuffix )}
562
+ filter = map [string ]string {"label" : generateClusterScopedIPHolderLinodeName (zone , options . Options .IpHolderSuffix )}
561
563
rawFilter , err = json .Marshal (filter )
562
564
if err != nil {
563
565
t .Errorf ("json marshal error: %v" , err )
@@ -592,7 +594,7 @@ func testCreateWithNoExistingIPHolderUsingLongSuffix(t *testing.T, mc *mocks.Moc
592
594
func testEnsureCiliumLoadBalancerDeletedWithOldIpHolderNamingConvention (t * testing.T , mc * mocks.MockClient ) {
593
595
t .Helper ()
594
596
595
- Options .BGPNodeSelector = nodeSelector
597
+ options . Options .BGPNodeSelector = nodeSelector
596
598
svc := createTestService ()
597
599
598
600
kubeClient , _ := k8sClient .NewFakeClientset ()
@@ -623,8 +625,8 @@ func testEnsureCiliumLoadBalancerDeletedWithOldIpHolderNamingConvention(t *testi
623
625
func testEnsureCiliumLoadBalancerDeletedWithNewIpHolderNamingConvention (t * testing.T , mc * mocks.MockClient ) {
624
626
t .Helper ()
625
627
626
- Options .BGPNodeSelector = nodeSelector
627
- Options .IpHolderSuffix = clusterName
628
+ options . Options .BGPNodeSelector = nodeSelector
629
+ options . Options .IpHolderSuffix = clusterName
628
630
svc := createTestService ()
629
631
newIpHolderInstance = createNewIpHolderInstance ()
630
632
@@ -643,7 +645,7 @@ func testEnsureCiliumLoadBalancerDeletedWithNewIpHolderNamingConvention(t *testi
643
645
t .Errorf ("json marshal error: %v" , err )
644
646
}
645
647
mc .EXPECT ().ListInstances (gomock .Any (), linodego .NewListOptions (1 , string (rawFilter ))).Times (1 ).Return ([]linodego.Instance {}, nil )
646
- filter = map [string ]string {"label" : generateClusterScopedIPHolderLinodeName (zone , Options .IpHolderSuffix )}
648
+ filter = map [string ]string {"label" : generateClusterScopedIPHolderLinodeName (zone , options . Options .IpHolderSuffix )}
647
649
rawFilter , err = json .Marshal (filter )
648
650
if err != nil {
649
651
t .Errorf ("json marshal error: %v" , err )
@@ -662,7 +664,7 @@ func testEnsureCiliumLoadBalancerDeletedWithNewIpHolderNamingConvention(t *testi
662
664
func testCiliumUpdateLoadBalancerAddNodeWithOldIpHolderNamingConvention (t * testing.T , mc * mocks.MockClient ) {
663
665
t .Helper ()
664
666
665
- Options .BGPNodeSelector = nodeSelector
667
+ options . Options .BGPNodeSelector = nodeSelector
666
668
svc := createTestService ()
667
669
668
670
kubeClient , _ := k8sClient .NewFakeClientset ()
@@ -723,8 +725,8 @@ func testCiliumUpdateLoadBalancerAddNodeWithOldIpHolderNamingConvention(t *testi
723
725
func testCiliumUpdateLoadBalancerAddNodeWithNewIpHolderNamingConvention (t * testing.T , mc * mocks.MockClient ) {
724
726
t .Helper ()
725
727
726
- Options .BGPNodeSelector = nodeSelector
727
- Options .IpHolderSuffix = clusterName
728
+ options . Options .BGPNodeSelector = nodeSelector
729
+ options . Options .IpHolderSuffix = clusterName
728
730
svc := createTestService ()
729
731
newIpHolderInstance = createNewIpHolderInstance ()
730
732
@@ -740,7 +742,7 @@ func testCiliumUpdateLoadBalancerAddNodeWithNewIpHolderNamingConvention(t *testi
740
742
t .Errorf ("json marshal error: %v" , err )
741
743
}
742
744
mc .EXPECT ().ListInstances (gomock .Any (), linodego .NewListOptions (1 , string (rawFilter ))).Times (1 ).Return ([]linodego.Instance {}, nil )
743
- filter = map [string ]string {"label" : generateClusterScopedIPHolderLinodeName (zone , Options .IpHolderSuffix )}
745
+ filter = map [string ]string {"label" : generateClusterScopedIPHolderLinodeName (zone , options . Options .IpHolderSuffix )}
744
746
rawFilter , err = json .Marshal (filter )
745
747
if err != nil {
746
748
t .Errorf ("json marshal error: %v" , err )
@@ -777,7 +779,7 @@ func testCiliumUpdateLoadBalancerAddNodeWithNewIpHolderNamingConvention(t *testi
777
779
t .Errorf ("json marshal error: %v" , err )
778
780
}
779
781
mc .EXPECT ().ListInstances (gomock .Any (), linodego .NewListOptions (1 , string (rawFilter ))).Times (1 ).Return ([]linodego.Instance {}, nil )
780
- filter = map [string ]string {"label" : generateClusterScopedIPHolderLinodeName (zone , Options .IpHolderSuffix )}
782
+ filter = map [string ]string {"label" : generateClusterScopedIPHolderLinodeName (zone , options . Options .IpHolderSuffix )}
781
783
rawFilter , err = json .Marshal (filter )
782
784
if err != nil {
783
785
t .Errorf ("json marshal error: %v" , err )
0 commit comments