Skip to content

Commit ed49ea2

Browse files
authored
Merge pull request #12216 from sbueringer/pr-move-infra-naming-strategy
⚠️ Move infrastructure namingStrategy field in ClusterClass
2 parents 095a054 + a7fb549 commit ed49ea2

File tree

14 files changed

+209
-134
lines changed

14 files changed

+209
-134
lines changed

api/v1beta1/conversion.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,48 @@ func (dst *MachineHealthCheck) ConvertFrom(srcRaw conversion.Hub) error {
9898
return Convert_v1beta2_MachineHealthCheck_To_v1beta1_MachineHealthCheck(src, dst, nil)
9999
}
100100

101+
func Convert_v1beta2_ClusterClassSpec_To_v1beta1_ClusterClassSpec(in *clusterv1.ClusterClassSpec, out *ClusterClassSpec, s apimachineryconversion.Scope) error {
102+
if err := autoConvert_v1beta2_ClusterClassSpec_To_v1beta1_ClusterClassSpec(in, out, s); err != nil {
103+
return err
104+
}
105+
106+
if in.Infrastructure.NamingStrategy != nil {
107+
out.InfrastructureNamingStrategy = &InfrastructureNamingStrategy{
108+
Template: in.Infrastructure.NamingStrategy.Template,
109+
}
110+
}
111+
return nil
112+
}
113+
114+
func Convert_v1beta2_InfrastructureClass_To_v1beta1_LocalObjectTemplate(in *clusterv1.InfrastructureClass, out *LocalObjectTemplate, s apimachineryconversion.Scope) error {
115+
if in == nil {
116+
return nil
117+
}
118+
119+
return autoConvert_v1beta2_LocalObjectTemplate_To_v1beta1_LocalObjectTemplate(&in.LocalObjectTemplate, out, s)
120+
}
121+
122+
func Convert_v1beta1_ClusterClassSpec_To_v1beta2_ClusterClassSpec(in *ClusterClassSpec, out *clusterv1.ClusterClassSpec, s apimachineryconversion.Scope) error {
123+
if err := autoConvert_v1beta1_ClusterClassSpec_To_v1beta2_ClusterClassSpec(in, out, s); err != nil {
124+
return err
125+
}
126+
127+
if in.InfrastructureNamingStrategy != nil {
128+
out.Infrastructure.NamingStrategy = &clusterv1.InfrastructureClassNamingStrategy{
129+
Template: in.InfrastructureNamingStrategy.Template,
130+
}
131+
}
132+
return nil
133+
}
134+
135+
func Convert_v1beta1_LocalObjectTemplate_To_v1beta2_InfrastructureClass(in *LocalObjectTemplate, out *clusterv1.InfrastructureClass, s apimachineryconversion.Scope) error {
136+
if in == nil {
137+
return nil
138+
}
139+
140+
return autoConvert_v1beta1_LocalObjectTemplate_To_v1beta2_LocalObjectTemplate(in, &out.LocalObjectTemplate, s)
141+
}
142+
101143
func Convert_v1beta2_ClusterClassStatus_To_v1beta1_ClusterClassStatus(in *clusterv1.ClusterClassStatus, out *ClusterClassStatus, s apimachineryconversion.Scope) error {
102144
if err := autoConvert_v1beta2_ClusterClassStatus_To_v1beta1_ClusterClassStatus(in, out, s); err != nil {
103145
return err

api/v1beta1/zz_generated.conversion.go

Lines changed: 23 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta2/clusterclass_types.go

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,10 @@ type ClusterClassSpec struct {
9898
// +kubebuilder:validation:MaxItems=32
9999
AvailabilityGates []ClusterAvailabilityGate `json:"availabilityGates,omitempty"`
100100

101-
// infrastructure is a reference to a provider-specific template that holds
102-
// the details for provisioning infrastructure specific cluster
103-
// for the underlying provider.
104-
// The underlying provider is responsible for the implementation
105-
// of the template to an infrastructure cluster.
101+
// infrastructure is a reference to a local struct that holds the details
102+
// for provisioning the infrastructure cluster for the Cluster.
106103
// +optional
107-
Infrastructure LocalObjectTemplate `json:"infrastructure,omitempty"`
108-
109-
// infrastructureNamingStrategy allows changing the naming pattern used when creating the infrastructure object.
110-
// +optional
111-
InfrastructureNamingStrategy *InfrastructureNamingStrategy `json:"infrastructureNamingStrategy,omitempty"`
104+
Infrastructure InfrastructureClass `json:"infrastructure,omitempty"`
112105

113106
// controlPlane is a reference to a local struct that holds the details
114107
// for provisioning the Control Plane for the Cluster.
@@ -135,6 +128,16 @@ type ClusterClassSpec struct {
135128
Patches []ClusterClassPatch `json:"patches,omitempty"`
136129
}
137130

131+
// InfrastructureClass defines the class for the infrastructure cluster.
132+
type InfrastructureClass struct {
133+
// LocalObjectTemplate contains the reference to a provider-specific infrastructure cluster template.
134+
LocalObjectTemplate `json:",inline"`
135+
136+
// namingStrategy allows changing the naming pattern used when creating the infrastructure cluster object.
137+
// +optional
138+
NamingStrategy *InfrastructureClassNamingStrategy `json:"namingStrategy,omitempty"`
139+
}
140+
138141
// ControlPlaneClass defines the class for the control plane.
139142
type ControlPlaneClass struct {
140143
// metadata is the metadata applied to the ControlPlane and the Machines of the ControlPlane
@@ -147,7 +150,7 @@ type ControlPlaneClass struct {
147150
// +optional
148151
Metadata ObjectMeta `json:"metadata,omitempty"`
149152

150-
// LocalObjectTemplate contains the reference to the control plane provider.
153+
// LocalObjectTemplate contains the reference to a provider-specific control plane template.
151154
LocalObjectTemplate `json:",inline"`
152155

153156
// machineInfrastructure defines the metadata and infrastructure information
@@ -221,8 +224,8 @@ type ControlPlaneClassNamingStrategy struct {
221224
Template *string `json:"template,omitempty"`
222225
}
223226

224-
// InfrastructureNamingStrategy defines the naming strategy for infrastructure objects.
225-
type InfrastructureNamingStrategy struct {
227+
// InfrastructureClassNamingStrategy defines the naming strategy for infrastructure objects.
228+
type InfrastructureClassNamingStrategy struct {
226229
// template defines the template to use for generating the name of the Infrastructure object.
227230
// If not defined, it will fallback to `{{ .cluster.name }}-{{ .random }}`.
228231
// If the templated string exceeds 63 characters, it will be trimmed to 58 characters and will

api/v1beta2/zz_generated.deepcopy.go

Lines changed: 25 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)