From 026364aff6cee1045271983e84082c610db5a422 Mon Sep 17 00:00:00 2001 From: Vivek Kumar Singh Date: Wed, 11 Dec 2024 10:49:33 +0530 Subject: [PATCH] rename the type to VSphereVMNamingStrategy --- apis/v1beta1/vspheremachine_types.go | 12 +++--- apis/v1beta1/zz_generated.deepcopy.go | 42 +++++++++---------- ...ture.cluster.x-k8s.io_vspheremachines.yaml | 6 +-- ...ster.x-k8s.io_vspheremachinetemplates.yaml | 6 +-- pkg/services/vimmachine.go | 2 +- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/apis/v1beta1/vspheremachine_types.go b/apis/v1beta1/vspheremachine_types.go index e772286e4..fb9a58493 100644 --- a/apis/v1beta1/vspheremachine_types.go +++ b/apis/v1beta1/vspheremachine_types.go @@ -69,14 +69,14 @@ type VSphereMachineSpec struct { // +optional GuestSoftPowerOffTimeout *metav1.Duration `json:"guestSoftPowerOffTimeout,omitempty"` - // NamingStrategy allows configuring the naming strategy used when calculating the name of the VirtualMachine. + // NamingStrategy allows configuring the naming strategy used when calculating the name of the VSphereVMs. // +optional - NamingStrategy *VirtualMachineNamingStrategy `json:"namingStrategy,omitempty"` + NamingStrategy *VSphereVMNamingStrategy `json:"namingStrategy,omitempty"` } -// VirtualMachineNamingStrategy defines the naming strategy for the VirtualMachines. -type VirtualMachineNamingStrategy struct { - // Template defines the template to use for generating the name of the VirtualMachine object. +// VSphereVMNamingStrategy defines the naming strategy for the VSphereVMs. +type VSphereVMNamingStrategy struct { + // Template defines the template to use for generating the name of the VSphereVMs object. // If not defined, it will fall back to `{{ .machine.name }}`. // The templating has the following data available: // * `.machine.name`: The name of the Machine object. @@ -86,7 +86,7 @@ type VirtualMachineNamingStrategy struct { // Notes: // * While the template offers some flexibility, we would like the name to link to the Machine name // to ensure better user experience when troubleshooting - // * Generated names must be valid Kubernetes names as they are used to create a VirtualMachine object + // * Generated names must be valid Kubernetes names as they are used to create a VSphereVMs object // and usually also as the name of the Node object. // * Names are automatically truncated at 63 characters. Please note that this can lead to name conflicts, // so we highly recommend to use a template which leads to a name shorter than 63 characters. diff --git a/apis/v1beta1/zz_generated.deepcopy.go b/apis/v1beta1/zz_generated.deepcopy.go index 8cc6469b5..20a2fdeaf 100644 --- a/apis/v1beta1/zz_generated.deepcopy.go +++ b/apis/v1beta1/zz_generated.deepcopy.go @@ -1050,7 +1050,7 @@ func (in *VSphereMachineSpec) DeepCopyInto(out *VSphereMachineSpec) { } if in.NamingStrategy != nil { in, out := &in.NamingStrategy, &out.NamingStrategy - *out = new(VirtualMachineNamingStrategy) + *out = new(VSphereVMNamingStrategy) (*in).DeepCopyInto(*out) } } @@ -1259,6 +1259,26 @@ func (in *VSphereVMList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VSphereVMNamingStrategy) DeepCopyInto(out *VSphereVMNamingStrategy) { + *out = *in + if in.Template != nil { + in, out := &in.Template, &out.Template + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VSphereVMNamingStrategy. +func (in *VSphereVMNamingStrategy) DeepCopy() *VSphereVMNamingStrategy { + if in == nil { + return nil + } + out := new(VSphereVMNamingStrategy) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VSphereVMSpec) DeepCopyInto(out *VSphereVMSpec) { *out = *in @@ -1396,23 +1416,3 @@ func (in *VirtualMachineCloneSpec) DeepCopy() *VirtualMachineCloneSpec { in.DeepCopyInto(out) return out } - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *VirtualMachineNamingStrategy) DeepCopyInto(out *VirtualMachineNamingStrategy) { - *out = *in - if in.Template != nil { - in, out := &in.Template, &out.Template - *out = new(string) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualMachineNamingStrategy. -func (in *VirtualMachineNamingStrategy) DeepCopy() *VirtualMachineNamingStrategy { - if in == nil { - return nil - } - out := new(VirtualMachineNamingStrategy) - in.DeepCopyInto(out) - return out -} diff --git a/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachines.yaml b/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachines.yaml index 5b48aa859..f09c4e69f 100644 --- a/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachines.yaml +++ b/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachines.yaml @@ -1028,11 +1028,11 @@ spec: type: integer namingStrategy: description: NamingStrategy allows configuring the naming strategy - used when calculating the name of the VirtualMachine. + used when calculating the name of the VSphereVMs. properties: template: description: |- - Template defines the template to use for generating the name of the VirtualMachine object. + Template defines the template to use for generating the name of the VSphereVMs object. If not defined, it will fall back to `{{ .machine.name }}`. The templating has the following data available: * `.machine.name`: The name of the Machine object. @@ -1042,7 +1042,7 @@ spec: Notes: * While the template offers some flexibility, we would like the name to link to the Machine name to ensure better user experience when troubleshooting - * Generated names must be valid Kubernetes names as they are used to create a VirtualMachine object + * Generated names must be valid Kubernetes names as they are used to create a VSphereVMs object and usually also as the name of the Node object. * Names are automatically truncated at 63 characters. Please note that this can lead to name conflicts, so we highly recommend to use a template which leads to a name shorter than 63 characters. diff --git a/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml b/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml index 16401bad0..49ccbb054 100644 --- a/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml +++ b/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml @@ -898,11 +898,11 @@ spec: type: integer namingStrategy: description: NamingStrategy allows configuring the naming - strategy used when calculating the name of the VirtualMachine. + strategy used when calculating the name of the VSphereVMs. properties: template: description: |- - Template defines the template to use for generating the name of the VirtualMachine object. + Template defines the template to use for generating the name of the VSphereVMs object. If not defined, it will fall back to `{{ .machine.name }}`. The templating has the following data available: * `.machine.name`: The name of the Machine object. @@ -912,7 +912,7 @@ spec: Notes: * While the template offers some flexibility, we would like the name to link to the Machine name to ensure better user experience when troubleshooting - * Generated names must be valid Kubernetes names as they are used to create a VirtualMachine object + * Generated names must be valid Kubernetes names as they are used to create a VSphereVMs object and usually also as the name of the Node object. * Names are automatically truncated at 63 characters. Please note that this can lead to name conflicts, so we highly recommend to use a template which leads to a name shorter than 63 characters. diff --git a/pkg/services/vimmachine.go b/pkg/services/vimmachine.go index 5b7830bc9..3162143f1 100644 --- a/pkg/services/vimmachine.go +++ b/pkg/services/vimmachine.go @@ -443,7 +443,7 @@ var nameTemplateFuncs = map[string]any{ var nameTpl = template.New("name generator").Funcs(nameTemplateFuncs).Option("missingkey=error") // GenerateVirtualMachineName generates the name of a VirtualMachine based on the naming strategy. -func GenerateVirtualMachineName(machineName string, namingStrategy *infrav1.VirtualMachineNamingStrategy) (string, error) { +func GenerateVirtualMachineName(machineName string, namingStrategy *infrav1.VSphereVMNamingStrategy) (string, error) { // Per default the name of the VirtualMachine should be equal to the Machine name (this is the same as "{{ .machine.name }}") if namingStrategy == nil || namingStrategy.Template == nil { // Note: No need to trim to max length in this case as valid Machine names will also be valid VirtualMachine names.