diff --git a/api/v1beta1/common_types.go b/api/v1beta1/common_types.go index d505d1420413..3db08c79af79 100644 --- a/api/v1beta1/common_types.go +++ b/api/v1beta1/common_types.go @@ -120,6 +120,10 @@ const ( // instead of being a source of truth for eventual consistency. // This annotation can be used to inform MachinePool status during in-progress scaling scenarios. ReplicasManagedByAnnotation = "cluster.x-k8s.io/replicas-managed-by" + + // VariableDefinitionFromInline indicates a patch or variable was defined in the `.spec` of a ClusterClass + // rather than from an external patch extension. + VariableDefinitionFromInline = "inline" ) const ( diff --git a/internal/webhooks/patch_validation.go b/internal/webhooks/patch_validation.go index c8c3cb6e1bc6..1b026116b91b 100644 --- a/internal/webhooks/patch_validation.go +++ b/internal/webhooks/patch_validation.go @@ -69,6 +69,14 @@ func validatePatchName(patch clusterv1.ClusterClassPatch, names sets.Set[string] ), ) } + if patch.Name == clusterv1.VariableDefinitionFromInline { + allErrs = append(allErrs, + field.Required( + path.Child("name"), + "\"inline\" can not be used as the name of a patch", + ), + ) + } if names.Has(patch.Name) { allErrs = append(allErrs,