Skip to content

Commit a686606

Browse files
committed
fixup! Add validation that ensures worker topology names are valid Kubernetes resource names
Explain why we use IsValidLabelValue check
1 parent b10eee5 commit a686606

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

internal/topology/check/compatibility.go

+10
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,11 @@ func MachineDeploymentTopologiesAreValidAndDefinedInClusterClass(desired *cluste
326326
}
327327

328328
// The Name must also be a valid label value, because it is used in some label values.
329+
//
330+
// NOTE This check always returns true in practice, because OpenAPI validation in the
331+
// Cluster CRD ensures that md.Name is <= 63 characters, and the IsDNS1123Subdomain check
332+
// accepts a smaller set of characters than IsValidLabelValue. We keep this check to be able
333+
// to unit test this function.
329334
if errs := validation.IsValidLabelValue(md.Name); len(errs) != 0 {
330335
for _, err := range errs {
331336
allErrs = append(
@@ -406,6 +411,11 @@ func MachinePoolTopologiesAreValidAndDefinedInClusterClass(desired *clusterv1.Cl
406411
}
407412

408413
// The Name must also be a valid label value, because it is used in some label values.
414+
//
415+
// NOTE This check always returns true in practice, because OpenAPI validation in the
416+
// Cluster CRD ensures that md.Name is <= 63 characters, and the IsDNS1123Subdomain check
417+
// accepts a smaller set of characters than IsValidLabelValue. We keep this check to be able
418+
// to unit test this function.
409419
if errs := validation.IsValidLabelValue(mp.Name); len(errs) != 0 {
410420
for _, err := range errs {
411421
allErrs = append(

0 commit comments

Comments
 (0)