@@ -41,6 +41,7 @@ import (
41
41
"sigs.k8s.io/cluster-api/internal/hooks"
42
42
fakeruntimeclient "sigs.k8s.io/cluster-api/internal/runtime/client/fake"
43
43
"sigs.k8s.io/cluster-api/internal/test/builder"
44
+ "sigs.k8s.io/cluster-api/util"
44
45
)
45
46
46
47
var (
@@ -328,8 +329,8 @@ func TestComputeControlPlane(t *testing.T) {
328
329
template : blueprint .ControlPlane .Template ,
329
330
currentRef : nil ,
330
331
obj : obj ,
331
- labels : mergeMap (blueprint .Topology .ControlPlane .Metadata .Labels , blueprint .ClusterClass .Spec .ControlPlane .Metadata .Labels ),
332
- annotations : mergeMap (blueprint .Topology .ControlPlane .Metadata .Annotations , blueprint .ClusterClass .Spec .ControlPlane .Metadata .Annotations ),
332
+ labels : util . MergeMap (blueprint .Topology .ControlPlane .Metadata .Labels , blueprint .ClusterClass .Spec .ControlPlane .Metadata .Labels ),
333
+ annotations : util . MergeMap (blueprint .Topology .ControlPlane .Metadata .Annotations , blueprint .ClusterClass .Spec .ControlPlane .Metadata .Annotations ),
333
334
})
334
335
335
336
assertNestedField (g , obj , version , contract .ControlPlane ().Version ().Path ()... )
@@ -419,8 +420,8 @@ func TestComputeControlPlane(t *testing.T) {
419
420
template : blueprint .ControlPlane .Template ,
420
421
currentRef : nil ,
421
422
obj : obj ,
422
- labels : mergeMap (blueprint .Topology .ControlPlane .Metadata .Labels , blueprint .ClusterClass .Spec .ControlPlane .Metadata .Labels ),
423
- annotations : mergeMap (blueprint .Topology .ControlPlane .Metadata .Annotations , blueprint .ClusterClass .Spec .ControlPlane .Metadata .Annotations ),
423
+ labels : util . MergeMap (blueprint .Topology .ControlPlane .Metadata .Labels , blueprint .ClusterClass .Spec .ControlPlane .Metadata .Labels ),
424
+ annotations : util . MergeMap (blueprint .Topology .ControlPlane .Metadata .Annotations , blueprint .ClusterClass .Spec .ControlPlane .Metadata .Annotations ),
424
425
})
425
426
426
427
assertNestedField (g , obj , version , contract .ControlPlane ().Version ().Path ()... )
@@ -471,18 +472,18 @@ func TestComputeControlPlane(t *testing.T) {
471
472
template : controlPlaneTemplateWithoutMachineTemplate ,
472
473
currentRef : nil ,
473
474
obj : obj ,
474
- labels : mergeMap (blueprint .Topology .ControlPlane .Metadata .Labels , blueprint .ClusterClass .Spec .ControlPlane .Metadata .Labels ),
475
- annotations : mergeMap (blueprint .Topology .ControlPlane .Metadata .Annotations , blueprint .ClusterClass .Spec .ControlPlane .Metadata .Annotations ),
475
+ labels : util . MergeMap (blueprint .Topology .ControlPlane .Metadata .Labels , blueprint .ClusterClass .Spec .ControlPlane .Metadata .Labels ),
476
+ annotations : util . MergeMap (blueprint .Topology .ControlPlane .Metadata .Annotations , blueprint .ClusterClass .Spec .ControlPlane .Metadata .Annotations ),
476
477
})
477
478
gotMetadata , err := contract .ControlPlane ().MachineTemplate ().Metadata ().Get (obj )
478
479
g .Expect (err ).ToNot (HaveOccurred ())
479
480
480
- expectedLabels := mergeMap (s .Current .Cluster .Spec .Topology .ControlPlane .Metadata .Labels , blueprint .ClusterClass .Spec .ControlPlane .Metadata .Labels , controlPlaneMachineTemplateLabels )
481
+ expectedLabels := util . MergeMap (s .Current .Cluster .Spec .Topology .ControlPlane .Metadata .Labels , blueprint .ClusterClass .Spec .ControlPlane .Metadata .Labels , controlPlaneMachineTemplateLabels )
481
482
expectedLabels [clusterv1 .ClusterNameLabel ] = cluster .Name
482
483
expectedLabels [clusterv1 .ClusterTopologyOwnedLabel ] = ""
483
484
g .Expect (gotMetadata ).To (Equal (& clusterv1.ObjectMeta {
484
485
Labels : expectedLabels ,
485
- Annotations : mergeMap (s .Current .Cluster .Spec .Topology .ControlPlane .Metadata .Annotations , blueprint .ClusterClass .Spec .ControlPlane .Metadata .Annotations , controlPlaneMachineTemplateAnnotations ),
486
+ Annotations : util . MergeMap (s .Current .Cluster .Spec .Topology .ControlPlane .Metadata .Annotations , blueprint .ClusterClass .Spec .ControlPlane .Metadata .Annotations , controlPlaneMachineTemplateAnnotations ),
486
487
}))
487
488
488
489
assertNestedField (g , obj , version , contract .ControlPlane ().Version ().Path ()... )
@@ -525,8 +526,8 @@ func TestComputeControlPlane(t *testing.T) {
525
526
template : blueprint .ControlPlane .Template ,
526
527
currentRef : scope .Current .Cluster .Spec .ControlPlaneRef ,
527
528
obj : obj ,
528
- labels : mergeMap (blueprint .Topology .ControlPlane .Metadata .Labels , blueprint .ClusterClass .Spec .ControlPlane .Metadata .Labels ),
529
- annotations : mergeMap (blueprint .Topology .ControlPlane .Metadata .Annotations , blueprint .ClusterClass .Spec .ControlPlane .Metadata .Annotations ),
529
+ labels : util . MergeMap (blueprint .Topology .ControlPlane .Metadata .Labels , blueprint .ClusterClass .Spec .ControlPlane .Metadata .Labels ),
530
+ annotations : util . MergeMap (blueprint .Topology .ControlPlane .Metadata .Annotations , blueprint .ClusterClass .Spec .ControlPlane .Metadata .Annotations ),
530
531
})
531
532
})
532
533
t .Run ("Should choose the correct version for control plane" , func (t * testing.T ) {
@@ -1485,13 +1486,13 @@ func TestComputeMachineDeployment(t *testing.T) {
1485
1486
g .Expect (actualMd .Name ).To (ContainSubstring ("cluster1" ))
1486
1487
g .Expect (actualMd .Name ).To (ContainSubstring ("big-pool-of-machines" ))
1487
1488
1488
- expectedAnnotations := mergeMap (mdTopology .Metadata .Annotations , md1 .Template .Metadata .Annotations )
1489
+ expectedAnnotations := util . MergeMap (mdTopology .Metadata .Annotations , md1 .Template .Metadata .Annotations )
1489
1490
delete (expectedAnnotations , clusterv1 .ClusterTopologyHoldUpgradeSequenceAnnotation )
1490
1491
delete (expectedAnnotations , clusterv1 .ClusterTopologyDeferUpgradeAnnotation )
1491
1492
g .Expect (actualMd .Annotations ).To (Equal (expectedAnnotations ))
1492
1493
g .Expect (actualMd .Spec .Template .ObjectMeta .Annotations ).To (Equal (expectedAnnotations ))
1493
1494
1494
- g .Expect (actualMd .Labels ).To (Equal (mergeMap (mdTopology .Metadata .Labels , md1 .Template .Metadata .Labels , map [string ]string {
1495
+ g .Expect (actualMd .Labels ).To (Equal (util . MergeMap (mdTopology .Metadata .Labels , md1 .Template .Metadata .Labels , map [string ]string {
1495
1496
clusterv1 .ClusterNameLabel : cluster .Name ,
1496
1497
clusterv1 .ClusterTopologyOwnedLabel : "" ,
1497
1498
clusterv1 .ClusterTopologyMachineDeploymentNameLabel : "big-pool-of-machines" ,
@@ -1501,7 +1502,7 @@ func TestComputeMachineDeployment(t *testing.T) {
1501
1502
clusterv1 .ClusterTopologyOwnedLabel : "" ,
1502
1503
clusterv1 .ClusterTopologyMachineDeploymentNameLabel : "big-pool-of-machines" ,
1503
1504
}))
1504
- g .Expect (actualMd .Spec .Template .ObjectMeta .Labels ).To (Equal (mergeMap (mdTopology .Metadata .Labels , md1 .Template .Metadata .Labels , map [string ]string {
1505
+ g .Expect (actualMd .Spec .Template .ObjectMeta .Labels ).To (Equal (util . MergeMap (mdTopology .Metadata .Labels , md1 .Template .Metadata .Labels , map [string ]string {
1505
1506
clusterv1 .ClusterNameLabel : cluster .Name ,
1506
1507
clusterv1 .ClusterTopologyOwnedLabel : "" ,
1507
1508
clusterv1 .ClusterTopologyMachineDeploymentNameLabel : "big-pool-of-machines" ,
@@ -1578,13 +1579,13 @@ func TestComputeMachineDeployment(t *testing.T) {
1578
1579
g .Expect (* actualMd .Spec .Template .Spec .FailureDomain ).To (Equal (topologyFailureDomain ))
1579
1580
g .Expect (actualMd .Name ).To (Equal ("existing-deployment-1" ))
1580
1581
1581
- expectedAnnotations := mergeMap (mdTopology .Metadata .Annotations , md1 .Template .Metadata .Annotations )
1582
+ expectedAnnotations := util . MergeMap (mdTopology .Metadata .Annotations , md1 .Template .Metadata .Annotations )
1582
1583
delete (expectedAnnotations , clusterv1 .ClusterTopologyHoldUpgradeSequenceAnnotation )
1583
1584
delete (expectedAnnotations , clusterv1 .ClusterTopologyDeferUpgradeAnnotation )
1584
1585
g .Expect (actualMd .Annotations ).To (Equal (expectedAnnotations ))
1585
1586
g .Expect (actualMd .Spec .Template .ObjectMeta .Annotations ).To (Equal (expectedAnnotations ))
1586
1587
1587
- g .Expect (actualMd .Labels ).To (Equal (mergeMap (mdTopology .Metadata .Labels , md1 .Template .Metadata .Labels , map [string ]string {
1588
+ g .Expect (actualMd .Labels ).To (Equal (util . MergeMap (mdTopology .Metadata .Labels , md1 .Template .Metadata .Labels , map [string ]string {
1588
1589
clusterv1 .ClusterNameLabel : cluster .Name ,
1589
1590
clusterv1 .ClusterTopologyOwnedLabel : "" ,
1590
1591
clusterv1 .ClusterTopologyMachineDeploymentNameLabel : "big-pool-of-machines" ,
@@ -1594,7 +1595,7 @@ func TestComputeMachineDeployment(t *testing.T) {
1594
1595
clusterv1 .ClusterTopologyOwnedLabel : "" ,
1595
1596
clusterv1 .ClusterTopologyMachineDeploymentNameLabel : "big-pool-of-machines" ,
1596
1597
}))
1597
- g .Expect (actualMd .Spec .Template .ObjectMeta .Labels ).To (Equal (mergeMap (mdTopology .Metadata .Labels , md1 .Template .Metadata .Labels , map [string ]string {
1598
+ g .Expect (actualMd .Spec .Template .ObjectMeta .Labels ).To (Equal (util . MergeMap (mdTopology .Metadata .Labels , md1 .Template .Metadata .Labels , map [string ]string {
1598
1599
clusterv1 .ClusterNameLabel : cluster .Name ,
1599
1600
clusterv1 .ClusterTopologyOwnedLabel : "" ,
1600
1601
clusterv1 .ClusterTopologyMachineDeploymentNameLabel : "big-pool-of-machines" ,
@@ -2267,7 +2268,7 @@ func TestMergeMap(t *testing.T) {
2267
2268
t .Run ("Merge maps" , func (t * testing.T ) {
2268
2269
g := NewWithT (t )
2269
2270
2270
- m := mergeMap (
2271
+ m := util . MergeMap (
2271
2272
map [string ]string {
2272
2273
"a" : "a" ,
2273
2274
"b" : "b" ,
@@ -2283,7 +2284,7 @@ func TestMergeMap(t *testing.T) {
2283
2284
t .Run ("Nils empty maps" , func (t * testing.T ) {
2284
2285
g := NewWithT (t )
2285
2286
2286
- m := mergeMap (map [string ]string {}, map [string ]string {})
2287
+ m := util . MergeMap (map [string ]string {}, map [string ]string {})
2287
2288
g .Expect (m ).To (BeNil ())
2288
2289
})
2289
2290
}
0 commit comments