@@ -363,7 +363,7 @@ func assertControlPlane(g Gomega, clusterClassObjects clusterClassObjects, clust
363
363
clusterv1 .TemplateClonedFromNameAnnotation : clusterClass .Spec .ControlPlane .MachineInfrastructure .Ref .Name ,
364
364
},
365
365
clusterClassObjects .ControlPlaneInfrastructureMachineTemplate .GetAnnotations (),
366
- ).without (corev1 .LastAppliedConfigAnnotation ),
366
+ ).without (g , corev1 .LastAppliedConfigAnnotation ),
367
367
))
368
368
369
369
// ControlPlane InfrastructureMachineTemplate.spec.template.metadata
@@ -395,7 +395,7 @@ func assertControlPlaneMachines(g Gomega, clusterObjects clusterObjects, cluster
395
395
g .Expect (
396
396
union (
397
397
machine .Annotations ,
398
- ).without (controlplanev1 .KubeadmClusterConfigurationAnnotation ),
398
+ ).without (g , controlplanev1 .KubeadmClusterConfigurationAnnotation ),
399
399
).To (BeEquivalentTo (
400
400
controlPlaneMachineTemplateMetadata .Annotations ,
401
401
))
@@ -443,7 +443,7 @@ func assertControlPlaneMachines(g Gomega, clusterObjects clusterObjects, cluster
443
443
g .Expect (
444
444
union (
445
445
bootstrapConfig .GetAnnotations (),
446
- ).ignore ( clusterv1 .MachineCertificatesExpiryDateAnnotation ),
446
+ ).without ( g , clusterv1 .MachineCertificatesExpiryDateAnnotation ),
447
447
).To (BeEquivalentTo (
448
448
controlPlaneMachineTemplateMetadata .Annotations ,
449
449
))
@@ -476,7 +476,7 @@ func assertMachineDeployments(g Gomega, clusterClassObjects clusterClassObjects,
476
476
g .Expect (
477
477
union (
478
478
machineDeployment .Annotations ,
479
- ).without (clusterv1 .RevisionAnnotation ),
479
+ ).without (g , clusterv1 .RevisionAnnotation ),
480
480
).To (BeEquivalentTo (
481
481
union (
482
482
mdTopology .Metadata .Annotations ,
@@ -535,7 +535,7 @@ func assertMachineDeployments(g Gomega, clusterClassObjects clusterClassObjects,
535
535
clusterv1 .TemplateClonedFromNameAnnotation : mdClass .Template .Infrastructure .Ref .Name ,
536
536
},
537
537
ccInfrastructureMachineTemplate .GetAnnotations (),
538
- ).without (corev1 .LastAppliedConfigAnnotation ),
538
+ ).without (g , corev1 .LastAppliedConfigAnnotation ),
539
539
))
540
540
// MachineDeployment InfrastructureMachineTemplate.spec.template.metadata
541
541
g .Expect (infrastructureMachineTemplateTemplateMetadata .Labels ).To (BeEquivalentTo (
@@ -567,7 +567,7 @@ func assertMachineDeployments(g Gomega, clusterClassObjects clusterClassObjects,
567
567
clusterv1 .TemplateClonedFromNameAnnotation : mdClass .Template .Bootstrap .Ref .Name ,
568
568
},
569
569
ccBootstrapConfigTemplate .GetAnnotations (),
570
- ).without (corev1 .LastAppliedConfigAnnotation ),
570
+ ).without (g , corev1 .LastAppliedConfigAnnotation ),
571
571
))
572
572
// MachineDeployment BootstrapConfigTemplate.spec.template.metadata
573
573
g .Expect (bootstrapConfigTemplateTemplateMetadata .Labels ).To (BeEquivalentTo (
@@ -602,11 +602,11 @@ func assertMachineSets(g Gomega, clusterObjects clusterObjects, cluster *cluster
602
602
g .Expect (
603
603
union (
604
604
machineSet .Annotations ,
605
- ).without (clusterv1 .DesiredReplicasAnnotation , clusterv1 .MaxReplicasAnnotation , clusterv1 .RevisionAnnotation ),
605
+ ).without (g , clusterv1 .DesiredReplicasAnnotation , clusterv1 .MaxReplicasAnnotation , clusterv1 .RevisionAnnotation ),
606
606
).To (BeEquivalentTo (
607
607
union (
608
608
machineDeployment .Annotations ,
609
- ).without (clusterv1 .RevisionAnnotation ),
609
+ ).without (g , clusterv1 .RevisionAnnotation ),
610
610
))
611
611
// MachineDeployment MachineSet.spec.selector
612
612
g .Expect (machineSet .Spec .Selector .MatchLabels ).To (BeEquivalentTo (
@@ -807,24 +807,11 @@ func union(maps ...map[string]string) unionMap {
807
807
808
808
// without removes keys from a unionMap.
809
809
// Note: This allows ignoring specific keys while comparing maps.
810
- func (m unionMap ) without (keys ... string ) unionMap {
810
+ func (m unionMap ) without (g Gomega , keys ... string ) unionMap {
811
811
for _ , key := range keys {
812
- // Fail if the key does not exist in the map.
813
- // Note: Failing here ensures we only use without for keys that actually exist.
814
- if _ , ok := m [key ]; ! ok {
815
- Fail (fmt .Sprintf ("key %q does not exist in map %s" , key , m ))
816
- }
817
-
818
- delete (m , key )
819
- }
820
- return m
821
- }
822
-
823
- // ignore removes keys from a unionMap only if they exist.
824
- // Note: This allows ignoring specific keys while comparing maps and is a more tolerant version of `without()`.
825
- func (m unionMap ) ignore (keys ... string ) unionMap {
826
- for _ , key := range keys {
827
- // Only remove the item from the map if it exists.
812
+ // Expect key to exist in the map to ensure without is only used for keys that actually exist.
813
+ _ , ok := m [key ]
814
+ g .Expect (ok ).To (BeTrue (), fmt .Sprintf ("key %q does not exist in map %s" , key , m ))
828
815
delete (m , key )
829
816
}
830
817
return m
0 commit comments