@@ -1333,6 +1333,66 @@ func TestMachineDeploymentTopologiesAreUniqueAndDefinedInClusterClass(t *testing
1333
1333
Build (),
1334
1334
wantErr : true ,
1335
1335
},
1336
+ {
1337
+ name : "fail if MachineDeploymentTopology name is not a valid Kubernetes resource name" ,
1338
+ clusterClass : builder .ClusterClass (metav1 .NamespaceDefault , "class1" ).
1339
+ WithInfrastructureClusterTemplate (
1340
+ builder .InfrastructureClusterTemplate (metav1 .NamespaceDefault , "infra1" ).Build ()).
1341
+ WithControlPlaneTemplate (
1342
+ builder .ControlPlane (metav1 .NamespaceDefault , "cp1" ).Build ()).
1343
+ WithControlPlaneInfrastructureMachineTemplate (
1344
+ builder .InfrastructureMachineTemplate (metav1 .NamespaceDefault , "cpinfra1" ).Build ()).
1345
+ WithWorkerMachineDeploymentClasses (
1346
+ * builder .MachineDeploymentClass ("aa" ).
1347
+ WithInfrastructureTemplate (
1348
+ builder .InfrastructureMachineTemplate (metav1 .NamespaceDefault , "infra1" ).Build ()).
1349
+ WithBootstrapTemplate (
1350
+ builder .BootstrapTemplate (metav1 .NamespaceDefault , "bootstrap1" ).Build ()).
1351
+ Build ()).
1352
+ Build (),
1353
+ cluster : builder .Cluster (metav1 .NamespaceDefault , "cluster1" ).
1354
+ WithTopology (
1355
+ builder .ClusterTopology ().
1356
+ WithClass ("class1" ).
1357
+ WithVersion ("v1.22.2" ).
1358
+ WithMachineDeployment (
1359
+ builder .MachineDeploymentTopology ("under_score" ).
1360
+ WithClass ("aa" ).
1361
+ Build ()).
1362
+ Build ()).
1363
+ Build (),
1364
+ wantErr : true ,
1365
+ },
1366
+ {
1367
+ name : "fail if MachineDeploymentTopology name is not a valid Kubernetes label value" ,
1368
+ clusterClass : builder .ClusterClass (metav1 .NamespaceDefault , "class1" ).
1369
+ WithInfrastructureClusterTemplate (
1370
+ builder .InfrastructureClusterTemplate (metav1 .NamespaceDefault , "infra1" ).Build ()).
1371
+ WithControlPlaneTemplate (
1372
+ builder .ControlPlane (metav1 .NamespaceDefault , "cp1" ).Build ()).
1373
+ WithControlPlaneInfrastructureMachineTemplate (
1374
+ builder .InfrastructureMachineTemplate (metav1 .NamespaceDefault , "cpinfra1" ).Build ()).
1375
+ WithWorkerMachineDeploymentClasses (
1376
+ * builder .MachineDeploymentClass ("aa" ).
1377
+ WithInfrastructureTemplate (
1378
+ builder .InfrastructureMachineTemplate (metav1 .NamespaceDefault , "infra1" ).Build ()).
1379
+ WithBootstrapTemplate (
1380
+ builder .BootstrapTemplate (metav1 .NamespaceDefault , "bootstrap1" ).Build ()).
1381
+ Build ()).
1382
+ Build (),
1383
+ cluster : builder .Cluster (metav1 .NamespaceDefault , "cluster1" ).
1384
+ WithTopology (
1385
+ builder .ClusterTopology ().
1386
+ WithClass ("class1" ).
1387
+ WithVersion ("v1.22.2" ).
1388
+ WithMachineDeployment (
1389
+ builder .MachineDeploymentTopology ("forward/slash" ).
1390
+ WithClass ("aa" ).
1391
+ Build ()).
1392
+ Build ()).
1393
+ Build (),
1394
+ wantErr : true ,
1395
+ },
1336
1396
}
1337
1397
for _ , tt := range tests {
1338
1398
t .Run (tt .name , func (t * testing.T ) {
@@ -1540,6 +1600,66 @@ func TestMachinePoolTopologiesAreUniqueAndDefinedInClusterClass(t *testing.T) {
1540
1600
Build (),
1541
1601
wantErr : true ,
1542
1602
},
1603
+ {
1604
+ name : "fail if MachinePoolTopology name is not a valid Kubernetes resource name" ,
1605
+ clusterClass : builder .ClusterClass (metav1 .NamespaceDefault , "class1" ).
1606
+ WithInfrastructureClusterTemplate (
1607
+ builder .InfrastructureClusterTemplate (metav1 .NamespaceDefault , "infra1" ).Build ()).
1608
+ WithControlPlaneTemplate (
1609
+ builder .ControlPlane (metav1 .NamespaceDefault , "cp1" ).Build ()).
1610
+ WithControlPlaneInfrastructureMachineTemplate (
1611
+ builder .InfrastructureMachinePoolTemplate (metav1 .NamespaceDefault , "cpinfra1" ).Build ()).
1612
+ WithWorkerMachinePoolClasses (
1613
+ * builder .MachinePoolClass ("aa" ).
1614
+ WithInfrastructureTemplate (
1615
+ builder .InfrastructureMachinePoolTemplate (metav1 .NamespaceDefault , "infra1" ).Build ()).
1616
+ WithBootstrapTemplate (
1617
+ builder .BootstrapTemplate (metav1 .NamespaceDefault , "bootstrap1" ).Build ()).
1618
+ Build ()).
1619
+ Build (),
1620
+ cluster : builder .Cluster (metav1 .NamespaceDefault , "cluster1" ).
1621
+ WithTopology (
1622
+ builder .ClusterTopology ().
1623
+ WithClass ("class1" ).
1624
+ WithVersion ("v1.22.2" ).
1625
+ WithMachinePool (
1626
+ builder .MachinePoolTopology ("under_score" ).
1627
+ WithClass ("aa" ).
1628
+ Build ()).
1629
+ Build ()).
1630
+ Build (),
1631
+ wantErr : true ,
1632
+ },
1633
+ {
1634
+ name : "fail if MachinePoolTopology name is not a valid Kubernetes label value" ,
1635
+ clusterClass : builder .ClusterClass (metav1 .NamespaceDefault , "class1" ).
1636
+ WithInfrastructureClusterTemplate (
1637
+ builder .InfrastructureClusterTemplate (metav1 .NamespaceDefault , "infra1" ).Build ()).
1638
+ WithControlPlaneTemplate (
1639
+ builder .ControlPlane (metav1 .NamespaceDefault , "cp1" ).Build ()).
1640
+ WithControlPlaneInfrastructureMachineTemplate (
1641
+ builder .InfrastructureMachinePoolTemplate (metav1 .NamespaceDefault , "cpinfra1" ).Build ()).
1642
+ WithWorkerMachinePoolClasses (
1643
+ * builder .MachinePoolClass ("aa" ).
1644
+ WithInfrastructureTemplate (
1645
+ builder .InfrastructureMachinePoolTemplate (metav1 .NamespaceDefault , "infra1" ).Build ()).
1646
+ WithBootstrapTemplate (
1647
+ builder .BootstrapTemplate (metav1 .NamespaceDefault , "bootstrap1" ).Build ()).
1648
+ Build ()).
1649
+ Build (),
1650
+ cluster : builder .Cluster (metav1 .NamespaceDefault , "cluster1" ).
1651
+ WithTopology (
1652
+ builder .ClusterTopology ().
1653
+ WithClass ("class1" ).
1654
+ WithVersion ("v1.22.2" ).
1655
+ WithMachinePool (
1656
+ builder .MachinePoolTopology ("forward/slash" ).
1657
+ WithClass ("aa" ).
1658
+ Build ()).
1659
+ Build ()).
1660
+ Build (),
1661
+ wantErr : true ,
1662
+ },
1543
1663
}
1544
1664
for _ , tt := range tests {
1545
1665
t .Run (tt .name , func (t * testing.T ) {
0 commit comments