diff --git a/internal/webhooks/clusterclass.go b/internal/webhooks/clusterclass.go index c259a1e4056f..6b7a78880b70 100644 --- a/internal/webhooks/clusterclass.go +++ b/internal/webhooks/clusterclass.go @@ -439,7 +439,7 @@ func validateNamingStrategies(clusterClass *clusterv1.ClusterClass) field.ErrorL if md.NamingStrategy == nil || md.NamingStrategy.Template == nil { continue } - name, err := names.MachineDeploymentNameGenerator(*md.NamingStrategy.Template, "cluster", "mdTopology").GenerateName() + name, err := names.MachineDeploymentNameGenerator(*md.NamingStrategy.Template, "cluster", "mdtopology").GenerateName() templateFldPath := field.NewPath("spec", "workers", "machineDeployments").Index(i).Child("namingStrategy", "template") if err != nil { allErrs = append(allErrs, @@ -459,7 +459,7 @@ func validateNamingStrategies(clusterClass *clusterv1.ClusterClass) field.ErrorL if mp.NamingStrategy == nil || mp.NamingStrategy.Template == nil { continue } - name, err := names.MachinePoolNameGenerator(*mp.NamingStrategy.Template, "cluster", "mpTopology").GenerateName() + name, err := names.MachinePoolNameGenerator(*mp.NamingStrategy.Template, "cluster", "mptopology").GenerateName() templateFldPath := field.NewPath("spec", "workers", "machinePools").Index(i).Child("namingStrategy", "template") if err != nil { allErrs = append(allErrs, diff --git a/internal/webhooks/clusterclass_test.go b/internal/webhooks/clusterclass_test.go index 330365dfec72..4eddd125bc94 100644 --- a/internal/webhooks/clusterclass_test.go +++ b/internal/webhooks/clusterclass_test.go @@ -1173,7 +1173,7 @@ func TestClusterClassValidation(t *testing.T) { WithControlPlaneTemplate( builder.ControlPlaneTemplate(metav1.NamespaceDefault, "cp1"). Build()). - WithControlPlaneNamingStrategy(&clusterv1.ControlPlaneClassNamingStrategy{Template: pointer.String("template-cp-{{ .cluster.name }}")}). + WithControlPlaneNamingStrategy(&clusterv1.ControlPlaneClassNamingStrategy{Template: pointer.String("{{ .cluster.name }}-cp-{{ .random }}")}). WithControlPlaneInfrastructureMachineTemplate( builder.InfrastructureMachineTemplate(metav1.NamespaceDefault, "cpInfra1"). Build()). @@ -1183,7 +1183,7 @@ func TestClusterClassValidation(t *testing.T) { builder.InfrastructureMachineTemplate(metav1.NamespaceDefault, "infra1").Build()). WithBootstrapTemplate( builder.BootstrapTemplate(metav1.NamespaceDefault, "bootstrap1").Build()). - WithNamingStrategy(&clusterv1.MachineDeploymentClassNamingStrategy{Template: pointer.String("template-md-{{ .cluster.name }}")}). + WithNamingStrategy(&clusterv1.MachineDeploymentClassNamingStrategy{Template: pointer.String("{{ .cluster.name }}-md-{{ .machineDeployment.topologyName }}-{{ .random }}")}). Build()). WithWorkerMachinePoolClasses( *builder.MachinePoolClass("bb"). @@ -1191,7 +1191,7 @@ func TestClusterClassValidation(t *testing.T) { builder.InfrastructureMachinePoolTemplate(metav1.NamespaceDefault, "infra2").Build()). WithBootstrapTemplate( builder.BootstrapTemplate(metav1.NamespaceDefault, "bootstrap2").Build()). - WithNamingStrategy(&clusterv1.MachinePoolClassNamingStrategy{Template: pointer.String("template-mp-{{ .cluster.name }}")}). + WithNamingStrategy(&clusterv1.MachinePoolClassNamingStrategy{Template: pointer.String("{{ .cluster.name }}-md-{{ .machinePool.topologyName }}-{{ .random }}")}). Build()). Build(), expectErr: false,