Skip to content

Commit

Permalink
Make 'inline' a reserved name for patches
Browse files Browse the repository at this point in the history
  • Loading branch information
killianmuldoon committed Jan 30, 2023
1 parent 1b61819 commit 0f94226
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/v1beta1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
8 changes: 8 additions & 0 deletions internal/webhooks/patch_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0f94226

Please sign in to comment.