Skip to content

Commit e5d9630

Browse files
committed
OpenStackClusterSpec: ApiServerLoadBalancer->pointer
Affects go marshalling only.
1 parent e39c730 commit e5d9630

17 files changed

+101
-40
lines changed

api/v1alpha5/conversion.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@ func Convert_v1beta1_OpenStackClusterSpec_To_v1alpha5_OpenStackClusterSpec(in *i
227227
out.AllowAllInClusterTraffic = in.ManagedSecurityGroups.AllowAllInClusterTraffic
228228
}
229229

230+
if in.APIServerLoadBalancer != nil {
231+
if err := Convert_v1beta1_APIServerLoadBalancer_To_v1alpha5_APIServerLoadBalancer(in.APIServerLoadBalancer, &out.APIServerLoadBalancer, s); err != nil {
232+
return err
233+
}
234+
}
235+
230236
out.CloudName = in.IdentityRef.CloudName
231237
out.IdentityRef = &OpenStackIdentityReference{Name: in.IdentityRef.Name}
232238

@@ -273,6 +279,13 @@ func Convert_v1alpha5_OpenStackClusterSpec_To_v1beta1_OpenStackClusterSpec(in *O
273279
}
274280
}
275281

282+
if in.APIServerLoadBalancer.Enabled {
283+
out.APIServerLoadBalancer = &infrav1.APIServerLoadBalancer{}
284+
if err := Convert_v1alpha5_APIServerLoadBalancer_To_v1beta1_APIServerLoadBalancer(&in.APIServerLoadBalancer, out.APIServerLoadBalancer, s); err != nil {
285+
return err
286+
}
287+
}
288+
276289
out.IdentityRef.CloudName = in.CloudName
277290
if in.IdentityRef != nil {
278291
out.IdentityRef.Name = in.IdentityRef.Name

api/v1alpha5/conversion_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func TestConvertFrom(t *testing.T) {
5151
},
5252
ObjectMeta: metav1.ObjectMeta{
5353
Annotations: map[string]string{
54-
"cluster.x-k8s.io/conversion-data": "{\"spec\":{\"apiServerLoadBalancer\":{},\"controlPlaneEndpoint\":{\"host\":\"\",\"port\":0},\"disableAPIServerFloatingIP\":false,\"disableExternalNetwork\":false,\"identityRef\":{\"cloudName\":\"\",\"name\":\"\"}},\"status\":{\"ready\":false}}",
54+
"cluster.x-k8s.io/conversion-data": "{\"spec\":{\"controlPlaneEndpoint\":{\"host\":\"\",\"port\":0},\"disableAPIServerFloatingIP\":false,\"disableExternalNetwork\":false,\"identityRef\":{\"cloudName\":\"\",\"name\":\"\"}},\"status\":{\"ready\":false}}",
5555
},
5656
},
5757
},
@@ -72,7 +72,7 @@ func TestConvertFrom(t *testing.T) {
7272
},
7373
ObjectMeta: metav1.ObjectMeta{
7474
Annotations: map[string]string{
75-
"cluster.x-k8s.io/conversion-data": "{\"spec\":{\"template\":{\"spec\":{\"apiServerLoadBalancer\":{},\"controlPlaneEndpoint\":{\"host\":\"\",\"port\":0},\"disableAPIServerFloatingIP\":false,\"disableExternalNetwork\":false,\"identityRef\":{\"cloudName\":\"\",\"name\":\"\"}}}}}",
75+
"cluster.x-k8s.io/conversion-data": "{\"spec\":{\"template\":{\"spec\":{\"controlPlaneEndpoint\":{\"host\":\"\",\"port\":0},\"disableAPIServerFloatingIP\":false,\"disableExternalNetwork\":false,\"identityRef\":{\"cloudName\":\"\",\"name\":\"\"}}}}}",
7676
},
7777
},
7878
},

api/v1alpha5/zz_generated.conversion.go

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

api/v1alpha6/openstackcluster_conversion.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ func restorev1beta1ClusterSpec(previous *infrav1.OpenStackClusterSpec, dst *infr
195195
if previous.ManagedSecurityGroups != nil {
196196
dst.ManagedSecurityGroups.AllNodesSecurityGroupRules = previous.ManagedSecurityGroups.AllNodesSecurityGroupRules
197197
}
198+
199+
if dst.APIServerLoadBalancer.IsZero() {
200+
dst.APIServerLoadBalancer = previous.APIServerLoadBalancer
201+
}
198202
}
199203

200204
func Convert_v1alpha6_OpenStackClusterSpec_To_v1beta1_OpenStackClusterSpec(in *OpenStackClusterSpec, out *infrav1.OpenStackClusterSpec, s apiconversion.Scope) error {
@@ -249,6 +253,14 @@ func Convert_v1alpha6_OpenStackClusterSpec_To_v1beta1_OpenStackClusterSpec(in *O
249253
out.IdentityRef.Name = in.IdentityRef.Name
250254
}
251255

256+
apiServerLoadBalancer := &infrav1.APIServerLoadBalancer{}
257+
if err := Convert_v1alpha6_APIServerLoadBalancer_To_v1beta1_APIServerLoadBalancer(&in.APIServerLoadBalancer, apiServerLoadBalancer, s); err != nil {
258+
return err
259+
}
260+
if !apiServerLoadBalancer.IsZero() {
261+
out.APIServerLoadBalancer = apiServerLoadBalancer
262+
}
263+
252264
return nil
253265
}
254266

@@ -287,6 +299,12 @@ func Convert_v1beta1_OpenStackClusterSpec_To_v1alpha6_OpenStackClusterSpec(in *i
287299
out.CloudName = in.IdentityRef.CloudName
288300
out.IdentityRef = &OpenStackIdentityReference{Name: in.IdentityRef.Name}
289301

302+
if in.APIServerLoadBalancer != nil {
303+
if err := Convert_v1beta1_APIServerLoadBalancer_To_v1alpha6_APIServerLoadBalancer(in.APIServerLoadBalancer, &out.APIServerLoadBalancer, s); err != nil {
304+
return err
305+
}
306+
}
307+
290308
return nil
291309
}
292310

api/v1alpha6/zz_generated.conversion.go

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

api/v1alpha7/openstackcluster_conversion.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ func restorev1beta1ClusterSpec(previous *infrav1.OpenStackClusterSpec, dst *infr
197197
if previous.ManagedSecurityGroups != nil {
198198
dst.ManagedSecurityGroups.AllNodesSecurityGroupRules = previous.ManagedSecurityGroups.AllNodesSecurityGroupRules
199199
}
200+
201+
if dst.APIServerLoadBalancer.IsZero() {
202+
dst.APIServerLoadBalancer = previous.APIServerLoadBalancer
203+
}
200204
}
201205

202206
func Convert_v1alpha7_OpenStackClusterSpec_To_v1beta1_OpenStackClusterSpec(in *OpenStackClusterSpec, out *infrav1.OpenStackClusterSpec, s apiconversion.Scope) error {
@@ -251,6 +255,14 @@ func Convert_v1alpha7_OpenStackClusterSpec_To_v1beta1_OpenStackClusterSpec(in *O
251255
out.IdentityRef.Name = in.IdentityRef.Name
252256
}
253257

258+
apiServerLoadBalancer := &infrav1.APIServerLoadBalancer{}
259+
if err := Convert_v1alpha7_APIServerLoadBalancer_To_v1beta1_APIServerLoadBalancer(&in.APIServerLoadBalancer, apiServerLoadBalancer, s); err != nil {
260+
return err
261+
}
262+
if !apiServerLoadBalancer.IsZero() {
263+
out.APIServerLoadBalancer = apiServerLoadBalancer
264+
}
265+
254266
return nil
255267
}
256268

@@ -289,6 +301,12 @@ func Convert_v1beta1_OpenStackClusterSpec_To_v1alpha7_OpenStackClusterSpec(in *i
289301
out.CloudName = in.IdentityRef.CloudName
290302
out.IdentityRef = &OpenStackIdentityReference{Name: in.IdentityRef.Name}
291303

304+
if in.APIServerLoadBalancer != nil {
305+
if err := Convert_v1beta1_APIServerLoadBalancer_To_v1alpha7_APIServerLoadBalancer(in.APIServerLoadBalancer, &out.APIServerLoadBalancer, s); err != nil {
306+
return err
307+
}
308+
}
309+
292310
return nil
293311
}
294312

api/v1alpha7/zz_generated.conversion.go

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

api/v1beta1/openstackcluster_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ type OpenStackClusterSpec struct {
9595
// APIServerLoadBalancer configures the optional LoadBalancer for the APIServer.
9696
// It must be activated by setting `enabled: true`.
9797
// +optional
98-
APIServerLoadBalancer APIServerLoadBalancer `json:"apiServerLoadBalancer,omitempty"`
98+
APIServerLoadBalancer *APIServerLoadBalancer `json:"apiServerLoadBalancer,omitempty"`
9999

100100
// DisableAPIServerFloatingIP determines whether or not to attempt to attach a floating
101101
// IP to the API server. This allows for the creation of clusters when attaching a floating

api/v1beta1/types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,14 @@ type APIServerLoadBalancer struct {
615615
Provider string `json:"provider,omitempty"`
616616
}
617617

618+
func (s *APIServerLoadBalancer) IsZero() bool {
619+
return s == nil || (!s.Enabled && len(s.AdditionalPorts) == 0 && len(s.AllowedCIDRs) == 0 && s.Provider == "")
620+
}
621+
622+
func (s *APIServerLoadBalancer) IsEnabled() bool {
623+
return s != nil && s.Enabled
624+
}
625+
618626
// ReferencedMachineResources contains resolved references to resources required by the machine.
619627
type ReferencedMachineResources struct {
620628
// ServerGroupID is the ID of the server group the machine should be added to and is calculated based on ServerGroupFilter.

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)