Skip to content

Commit 70bfdaf

Browse files
committed
OpenStackClusterSpec: ControlPlaneEndpoint->pointer
1 parent 9223883 commit 70bfdaf

18 files changed

+112
-38
lines changed

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\":{\"controlPlaneEndpoint\":{\"host\":\"\",\"port\":0},\"identityRef\":{\"cloudName\":\"\",\"name\":\"\"}},\"status\":{\"ready\":false}}",
54+
"cluster.x-k8s.io/conversion-data": "{\"spec\":{\"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\":{\"controlPlaneEndpoint\":{\"host\":\"\",\"port\":0},\"identityRef\":{\"cloudName\":\"\",\"name\":\"\"}}}}}",
75+
"cluster.x-k8s.io/conversion-data": "{\"spec\":{\"template\":{\"spec\":{\"identityRef\":{\"cloudName\":\"\",\"name\":\"\"}}}}}",
7676
},
7777
},
7878
},

api/v1alpha5/zz_generated.conversion.go

Lines changed: 2 additions & 2 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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"reflect"
2121

2222
apiconversion "k8s.io/apimachinery/pkg/conversion"
23+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2324
ctrlconversion "sigs.k8s.io/controller-runtime/pkg/conversion"
2425

2526
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1"
@@ -201,6 +202,10 @@ func restorev1beta1ClusterSpec(previous *infrav1.OpenStackClusterSpec, dst *infr
201202
dst.APIServerLoadBalancer = previous.APIServerLoadBalancer
202203
}
203204

205+
if dst.ControlPlaneEndpoint == nil || *dst.ControlPlaneEndpoint == (clusterv1.APIEndpoint{}) {
206+
dst.ControlPlaneEndpoint = previous.ControlPlaneEndpoint
207+
}
208+
204209
optional.RestoreString(&previous.APIServerFloatingIP, &dst.APIServerFloatingIP)
205210
optional.RestoreString(&previous.APIServerFixedIP, &dst.APIServerFixedIP)
206211
optional.RestoreInt(&previous.APIServerPort, &dst.APIServerPort)
@@ -256,6 +261,10 @@ func Convert_v1alpha6_OpenStackClusterSpec_To_v1beta1_OpenStackClusterSpec(in *O
256261
}
257262
}
258263

264+
if in.ControlPlaneEndpoint != (clusterv1.APIEndpoint{}) {
265+
out.ControlPlaneEndpoint = &in.ControlPlaneEndpoint
266+
}
267+
259268
out.IdentityRef.CloudName = in.CloudName
260269
if in.IdentityRef != nil {
261270
out.IdentityRef.Name = in.IdentityRef.Name
@@ -304,6 +313,10 @@ func Convert_v1beta1_OpenStackClusterSpec_To_v1alpha6_OpenStackClusterSpec(in *i
304313
out.AllowAllInClusterTraffic = in.ManagedSecurityGroups.AllowAllInClusterTraffic
305314
}
306315

316+
if in.ControlPlaneEndpoint != nil {
317+
out.ControlPlaneEndpoint = *in.ControlPlaneEndpoint
318+
}
319+
307320
out.CloudName = in.IdentityRef.CloudName
308321
out.IdentityRef = &OpenStackIdentityReference{Name: in.IdentityRef.Name}
309322

api/v1alpha6/zz_generated.conversion.go

Lines changed: 2 additions & 2 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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package v1alpha7
1818

1919
import (
2020
apiconversion "k8s.io/apimachinery/pkg/conversion"
21+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2122
ctrlconversion "sigs.k8s.io/controller-runtime/pkg/conversion"
2223

2324
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1"
@@ -203,6 +204,10 @@ func restorev1beta1ClusterSpec(previous *infrav1.OpenStackClusterSpec, dst *infr
203204
dst.APIServerLoadBalancer = previous.APIServerLoadBalancer
204205
}
205206

207+
if dst.ControlPlaneEndpoint == nil || *dst.ControlPlaneEndpoint == (clusterv1.APIEndpoint{}) {
208+
dst.ControlPlaneEndpoint = previous.ControlPlaneEndpoint
209+
}
210+
206211
optional.RestoreString(&previous.APIServerFloatingIP, &dst.APIServerFloatingIP)
207212
optional.RestoreString(&previous.APIServerFixedIP, &dst.APIServerFixedIP)
208213
optional.RestoreInt(&previous.APIServerPort, &dst.APIServerPort)
@@ -258,6 +263,10 @@ func Convert_v1alpha7_OpenStackClusterSpec_To_v1beta1_OpenStackClusterSpec(in *O
258263
}
259264
}
260265

266+
if in.ControlPlaneEndpoint != (clusterv1.APIEndpoint{}) {
267+
out.ControlPlaneEndpoint = &in.ControlPlaneEndpoint
268+
}
269+
261270
out.IdentityRef.CloudName = in.CloudName
262271
if in.IdentityRef != nil {
263272
out.IdentityRef.Name = in.IdentityRef.Name
@@ -306,6 +315,10 @@ func Convert_v1beta1_OpenStackClusterSpec_To_v1alpha7_OpenStackClusterSpec(in *i
306315
out.AllowAllInClusterTraffic = in.ManagedSecurityGroups.AllowAllInClusterTraffic
307316
}
308317

318+
if in.ControlPlaneEndpoint != nil {
319+
out.ControlPlaneEndpoint = *in.ControlPlaneEndpoint
320+
}
321+
309322
out.CloudName = in.IdentityRef.CloudName
310323
out.IdentityRef = &OpenStackIdentityReference{Name: in.IdentityRef.Name}
311324

api/v1alpha7/zz_generated.conversion.go

Lines changed: 2 additions & 2 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: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,13 @@ type OpenStackClusterSpec struct {
158158
Tags []string `json:"tags,omitempty"`
159159

160160
// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
161+
// It is normally populated automatically by the OpenStackCluster
162+
// controller during cluster provisioning. If it is set on creation the
163+
// control plane endpoint will use the values set here in preference to
164+
// values set elsewhere.
165+
// ControlPlaneEndpoint cannot be modified after ControlPlaneEndpoint.Host has been set.
161166
// +optional
162-
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"`
167+
ControlPlaneEndpoint *clusterv1.APIEndpoint `json:"controlPlaneEndpoint,omitempty"`
163168

164169
// ControlPlaneAvailabilityZones is the az to deploy control plane to
165170
// +listType=set

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.

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5536,8 +5536,13 @@ spec:
55365536
type: array
55375537
x-kubernetes-list-type: set
55385538
controlPlaneEndpoint:
5539-
description: ControlPlaneEndpoint represents the endpoint used to
5540-
communicate with the control plane.
5539+
description: |-
5540+
ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
5541+
It is normally populated automatically by the OpenStackCluster
5542+
controller during cluster provisioning. If it is set on creation the
5543+
control plane endpoint will use the values set here in preference to
5544+
values set elsewhere.
5545+
ControlPlaneEndpoint cannot be modified after ControlPlaneEndpoint.Host has been set.
55415546
properties:
55425547
host:
55435548
description: The hostname on which the API server is serving.

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclustertemplates.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2968,8 +2968,13 @@ spec:
29682968
type: array
29692969
x-kubernetes-list-type: set
29702970
controlPlaneEndpoint:
2971-
description: ControlPlaneEndpoint represents the endpoint
2972-
used to communicate with the control plane.
2971+
description: |-
2972+
ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
2973+
It is normally populated automatically by the OpenStackCluster
2974+
controller during cluster provisioning. If it is set on creation the
2975+
control plane endpoint will use the values set here in preference to
2976+
values set elsewhere.
2977+
ControlPlaneEndpoint cannot be modified after ControlPlaneEndpoint.Host has been set.
29732978
properties:
29742979
host:
29752980
description: The hostname on which the API server is serving.

0 commit comments

Comments
 (0)