Skip to content

Commit

Permalink
rename the type to VSphereVMNamingStrategy
Browse files Browse the repository at this point in the history
  • Loading branch information
viveksyngh committed Dec 11, 2024
1 parent 0deb41a commit 026364a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 34 deletions.
12 changes: 6 additions & 6 deletions apis/v1beta1/vspheremachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
42 changes: 21 additions & 21 deletions apis/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/vimmachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 026364a

Please sign in to comment.