From 1586dcd04328c6c2936821ebf817b2a0f9bae4e6 Mon Sep 17 00:00:00 2001 From: Jingyi Hu Date: Fri, 30 Aug 2024 22:37:33 +0000 Subject: [PATCH] tool: mark resourceID field as immutable in template --- dev/tools/controllerbuilder/template/apis/types.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dev/tools/controllerbuilder/template/apis/types.go b/dev/tools/controllerbuilder/template/apis/types.go index 003065bb78d..a83e7d7d9ec 100644 --- a/dev/tools/controllerbuilder/template/apis/types.go +++ b/dev/tools/controllerbuilder/template/apis/types.go @@ -40,6 +40,8 @@ var {{ .Kind }}GVK = GroupVersion.WithKind("{{ .Kind }}") // +kcc:proto={{ .KindProtoTag }} {{- end }} type {{ .Kind }}Spec struct { + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID is immutable" + // Immutable. // The {{ .Kind }} name. If not given, the metadata.name will be used. // + optional ResourceID *string ` + "`" + `json:"resourceID,omitempty"` + "`" + `