@@ -15,6 +15,8 @@ import (
1515 "k8s.io/client-go/kubernetes"
1616
1717 "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"
1820)
1921
2022const (
3234 Labels : map [string ]string {"cilium-bgp-peering" : "true" },
3335 },
3436 Spec : v1.NodeSpec {
35- ProviderID : fmt .Sprintf ("%s%d" , providerIDPrefix , 11111 ),
37+ ProviderID : fmt .Sprintf ("%s%d" , ccmUtils . ProviderIDPrefix , 11111 ),
3638 },
3739 },
3840 {
@@ -41,15 +43,15 @@ var (
4143 Labels : map [string ]string {"cilium-bgp-peering" : "true" },
4244 },
4345 Spec : v1.NodeSpec {
44- ProviderID : fmt .Sprintf ("%s%d" , providerIDPrefix , 22222 ),
46+ ProviderID : fmt .Sprintf ("%s%d" , ccmUtils . ProviderIDPrefix , 22222 ),
4547 },
4648 },
4749 {
4850 ObjectMeta : metav1.ObjectMeta {
4951 Name : "node-3" ,
5052 },
5153 Spec : v1.NodeSpec {
52- ProviderID : fmt .Sprintf ("%s%d" , providerIDPrefix , 33333 ),
54+ ProviderID : fmt .Sprintf ("%s%d" , ccmUtils . ProviderIDPrefix , 33333 ),
5355 },
5456 },
5557 {
6062 },
6163 },
6264 Spec : v1.NodeSpec {
63- ProviderID : fmt .Sprintf ("%s%d" , providerIDPrefix , 44444 ),
65+ ProviderID : fmt .Sprintf ("%s%d" , ccmUtils . ProviderIDPrefix , 44444 ),
6466 },
6567 },
6668 }
7173 Labels : map [string ]string {"cilium-bgp-peering" : "true" },
7274 },
7375 Spec : v1.NodeSpec {
74- ProviderID : fmt .Sprintf ("%s%d" , providerIDPrefix , 55555 ),
76+ ProviderID : fmt .Sprintf ("%s%d" , ccmUtils . ProviderIDPrefix , 55555 ),
7577 },
7678 },
7779 }
@@ -202,7 +204,7 @@ func addNodes(t *testing.T, kubeClient kubernetes.Interface, nodes []*v1.Node) {
202204func createNewIpHolderInstance () linodego.Instance {
203205 return linodego.Instance {
204206 ID : 123456 ,
205- Label : generateClusterScopedIPHolderLinodeName (zone , Options .IpHolderSuffix ),
207+ Label : generateClusterScopedIPHolderLinodeName (zone , options . Options .IpHolderSuffix ),
206208 Type : "g6-standard-1" ,
207209 Region : "us-west" ,
208210 IPv4 : []* net.IP {& publicIPv4 },
@@ -212,8 +214,8 @@ func createNewIpHolderInstance() linodego.Instance {
212214func testNoBGPNodeLabel (t * testing.T , mc * mocks.MockClient ) {
213215 t .Helper ()
214216
215- Options .BGPNodeSelector = ""
216- Options .IpHolderSuffix = clusterName
217+ options . Options .BGPNodeSelector = ""
218+ options . Options .IpHolderSuffix = clusterName
217219 t .Setenv ("BGP_PEER_PREFIX" , "2600:3cef" )
218220 svc := createTestService ()
219221 newIpHolderInstance = createNewIpHolderInstance ()
@@ -231,7 +233,7 @@ func testNoBGPNodeLabel(t *testing.T, mc *mocks.MockClient) {
231233 }
232234
233235 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 )}
235237 rawFilter , err = json .Marshal (filter )
236238 if err != nil {
237239 t .Errorf ("json marshal error: %v" , err )
@@ -271,7 +273,7 @@ func testNoBGPNodeLabel(t *testing.T, mc *mocks.MockClient) {
271273func testUnsupportedRegion (t * testing.T , mc * mocks.MockClient ) {
272274 t .Helper ()
273275
274- Options .BGPNodeSelector = nodeSelector
276+ options . Options .BGPNodeSelector = nodeSelector
275277 svc := createTestService ()
276278
277279 kubeClient , _ := k8sClient .NewFakeClientset ()
@@ -302,7 +304,7 @@ func testUnsupportedRegion(t *testing.T, mc *mocks.MockClient) {
302304func testCreateWithExistingIPHolderWithOldIpHolderNamingConvention (t * testing.T , mc * mocks.MockClient ) {
303305 t .Helper ()
304306
305- Options .BGPNodeSelector = nodeSelector
307+ options . Options .BGPNodeSelector = nodeSelector
306308 svc := createTestService ()
307309 newIpHolderInstance = createNewIpHolderInstance ()
308310
@@ -346,8 +348,8 @@ func testCreateWithExistingIPHolderWithOldIpHolderNamingConvention(t *testing.T,
346348func testCreateWithExistingIPHolderWithNewIpHolderNamingConvention (t * testing.T , mc * mocks.MockClient ) {
347349 t .Helper ()
348350
349- Options .BGPNodeSelector = nodeSelector
350- Options .IpHolderSuffix = clusterName
351+ options . Options .BGPNodeSelector = nodeSelector
352+ options . Options .IpHolderSuffix = clusterName
351353 svc := createTestService ()
352354 newIpHolderInstance = createNewIpHolderInstance ()
353355
@@ -391,8 +393,8 @@ func testCreateWithExistingIPHolderWithNewIpHolderNamingConvention(t *testing.T,
391393func testCreateWithExistingIPHolderWithNewIpHolderNamingConventionUsingLongSuffix (t * testing.T , mc * mocks.MockClient ) {
392394 t .Helper ()
393395
394- Options .BGPNodeSelector = nodeSelector
395- Options .IpHolderSuffix = "OaTJrRuufacHVougjwkpBpmstiqvswvBNEMWXsRYfMBTCkKIUTXpbGIcIbDWSQp"
396+ options . Options .BGPNodeSelector = nodeSelector
397+ options . Options .IpHolderSuffix = "OaTJrRuufacHVougjwkpBpmstiqvswvBNEMWXsRYfMBTCkKIUTXpbGIcIbDWSQp"
396398 svc := createTestService ()
397399 newIpHolderInstance = createNewIpHolderInstance ()
398400
@@ -436,8 +438,8 @@ func testCreateWithExistingIPHolderWithNewIpHolderNamingConventionUsingLongSuffi
436438func testCreateWithNoExistingIPHolderUsingNoSuffix (t * testing.T , mc * mocks.MockClient ) {
437439 t .Helper ()
438440
439- Options .BGPNodeSelector = nodeSelector
440- Options .IpHolderSuffix = ""
441+ options . Options .BGPNodeSelector = nodeSelector
442+ options . Options .IpHolderSuffix = ""
441443 svc := createTestService ()
442444 newIpHolderInstance = createNewIpHolderInstance ()
443445
@@ -453,7 +455,7 @@ func testCreateWithNoExistingIPHolderUsingNoSuffix(t *testing.T, mc *mocks.MockC
453455 t .Errorf ("json marshal error: %v" , err )
454456 }
455457 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 )}
457459 rawFilter , err = json .Marshal (filter )
458460 if err != nil {
459461 t .Errorf ("json marshal error: %v" , err )
@@ -488,8 +490,8 @@ func testCreateWithNoExistingIPHolderUsingNoSuffix(t *testing.T, mc *mocks.MockC
488490func testCreateWithNoExistingIPHolderUsingShortSuffix (t * testing.T , mc * mocks.MockClient ) {
489491 t .Helper ()
490492
491- Options .BGPNodeSelector = nodeSelector
492- Options .IpHolderSuffix = clusterName
493+ options . Options .BGPNodeSelector = nodeSelector
494+ options . Options .IpHolderSuffix = clusterName
493495 svc := createTestService ()
494496 newIpHolderInstance = createNewIpHolderInstance ()
495497
@@ -505,7 +507,7 @@ func testCreateWithNoExistingIPHolderUsingShortSuffix(t *testing.T, mc *mocks.Mo
505507 t .Errorf ("json marshal error: %v" , err )
506508 }
507509 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 )}
509511 rawFilter , err = json .Marshal (filter )
510512 if err != nil {
511513 t .Errorf ("json marshal error: %v" , err )
@@ -540,8 +542,8 @@ func testCreateWithNoExistingIPHolderUsingShortSuffix(t *testing.T, mc *mocks.Mo
540542func testCreateWithNoExistingIPHolderUsingLongSuffix (t * testing.T , mc * mocks.MockClient ) {
541543 t .Helper ()
542544
543- Options .BGPNodeSelector = nodeSelector
544- Options .IpHolderSuffix = "OaTJrRuufacHVougjwkpBpmstiqvswvBNEMWXsRYfMBTCkKIUTXpbGIcIbDWSQp"
545+ options . Options .BGPNodeSelector = nodeSelector
546+ options . Options .IpHolderSuffix = "OaTJrRuufacHVougjwkpBpmstiqvswvBNEMWXsRYfMBTCkKIUTXpbGIcIbDWSQp"
545547 svc := createTestService ()
546548 newIpHolderInstance = createNewIpHolderInstance ()
547549
@@ -557,7 +559,7 @@ func testCreateWithNoExistingIPHolderUsingLongSuffix(t *testing.T, mc *mocks.Moc
557559 t .Errorf ("json marshal error: %v" , err )
558560 }
559561 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 )}
561563 rawFilter , err = json .Marshal (filter )
562564 if err != nil {
563565 t .Errorf ("json marshal error: %v" , err )
@@ -592,7 +594,7 @@ func testCreateWithNoExistingIPHolderUsingLongSuffix(t *testing.T, mc *mocks.Moc
592594func testEnsureCiliumLoadBalancerDeletedWithOldIpHolderNamingConvention (t * testing.T , mc * mocks.MockClient ) {
593595 t .Helper ()
594596
595- Options .BGPNodeSelector = nodeSelector
597+ options . Options .BGPNodeSelector = nodeSelector
596598 svc := createTestService ()
597599
598600 kubeClient , _ := k8sClient .NewFakeClientset ()
@@ -623,8 +625,8 @@ func testEnsureCiliumLoadBalancerDeletedWithOldIpHolderNamingConvention(t *testi
623625func testEnsureCiliumLoadBalancerDeletedWithNewIpHolderNamingConvention (t * testing.T , mc * mocks.MockClient ) {
624626 t .Helper ()
625627
626- Options .BGPNodeSelector = nodeSelector
627- Options .IpHolderSuffix = clusterName
628+ options . Options .BGPNodeSelector = nodeSelector
629+ options . Options .IpHolderSuffix = clusterName
628630 svc := createTestService ()
629631 newIpHolderInstance = createNewIpHolderInstance ()
630632
@@ -643,7 +645,7 @@ func testEnsureCiliumLoadBalancerDeletedWithNewIpHolderNamingConvention(t *testi
643645 t .Errorf ("json marshal error: %v" , err )
644646 }
645647 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 )}
647649 rawFilter , err = json .Marshal (filter )
648650 if err != nil {
649651 t .Errorf ("json marshal error: %v" , err )
@@ -662,7 +664,7 @@ func testEnsureCiliumLoadBalancerDeletedWithNewIpHolderNamingConvention(t *testi
662664func testCiliumUpdateLoadBalancerAddNodeWithOldIpHolderNamingConvention (t * testing.T , mc * mocks.MockClient ) {
663665 t .Helper ()
664666
665- Options .BGPNodeSelector = nodeSelector
667+ options . Options .BGPNodeSelector = nodeSelector
666668 svc := createTestService ()
667669
668670 kubeClient , _ := k8sClient .NewFakeClientset ()
@@ -723,8 +725,8 @@ func testCiliumUpdateLoadBalancerAddNodeWithOldIpHolderNamingConvention(t *testi
723725func testCiliumUpdateLoadBalancerAddNodeWithNewIpHolderNamingConvention (t * testing.T , mc * mocks.MockClient ) {
724726 t .Helper ()
725727
726- Options .BGPNodeSelector = nodeSelector
727- Options .IpHolderSuffix = clusterName
728+ options . Options .BGPNodeSelector = nodeSelector
729+ options . Options .IpHolderSuffix = clusterName
728730 svc := createTestService ()
729731 newIpHolderInstance = createNewIpHolderInstance ()
730732
@@ -740,7 +742,7 @@ func testCiliumUpdateLoadBalancerAddNodeWithNewIpHolderNamingConvention(t *testi
740742 t .Errorf ("json marshal error: %v" , err )
741743 }
742744 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 )}
744746 rawFilter , err = json .Marshal (filter )
745747 if err != nil {
746748 t .Errorf ("json marshal error: %v" , err )
@@ -777,7 +779,7 @@ func testCiliumUpdateLoadBalancerAddNodeWithNewIpHolderNamingConvention(t *testi
777779 t .Errorf ("json marshal error: %v" , err )
778780 }
779781 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 )}
781783 rawFilter , err = json .Marshal (filter )
782784 if err != nil {
783785 t .Errorf ("json marshal error: %v" , err )
0 commit comments