Skip to content

Commit 9223883

Browse files
committed
OpenStackClusterSpec: scalar fields to optional types
The following types become a corresponding optional type: * NetworkMTU * DisableExternalNetwork * DisableAPIServerFloatingIP * DisablePortSecurity * ControlPlaneOmitAvailabilityZone
1 parent 2c7b44b commit 9223883

20 files changed

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

api/v1alpha5/zz_generated.conversion.go

Lines changed: 12 additions & 4 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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ func restorev1beta1ClusterSpec(previous *infrav1.OpenStackClusterSpec, dst *infr
204204
optional.RestoreString(&previous.APIServerFloatingIP, &dst.APIServerFloatingIP)
205205
optional.RestoreString(&previous.APIServerFixedIP, &dst.APIServerFixedIP)
206206
optional.RestoreInt(&previous.APIServerPort, &dst.APIServerPort)
207+
optional.RestoreBool(&previous.DisableAPIServerFloatingIP, &dst.DisableAPIServerFloatingIP)
208+
optional.RestoreBool(&previous.ControlPlaneOmitAvailabilityZone, &dst.ControlPlaneOmitAvailabilityZone)
209+
optional.RestoreBool(&previous.DisablePortSecurity, &dst.DisablePortSecurity)
207210
}
208211

209212
func Convert_v1alpha6_OpenStackClusterSpec_To_v1beta1_OpenStackClusterSpec(in *OpenStackClusterSpec, out *infrav1.OpenStackClusterSpec, s apiconversion.Scope) error {

api/v1alpha6/zz_generated.conversion.go

Lines changed: 18 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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ func restorev1beta1ClusterSpec(previous *infrav1.OpenStackClusterSpec, dst *infr
206206
optional.RestoreString(&previous.APIServerFloatingIP, &dst.APIServerFloatingIP)
207207
optional.RestoreString(&previous.APIServerFixedIP, &dst.APIServerFixedIP)
208208
optional.RestoreInt(&previous.APIServerPort, &dst.APIServerPort)
209+
optional.RestoreBool(&previous.DisableAPIServerFloatingIP, &dst.DisableAPIServerFloatingIP)
210+
optional.RestoreBool(&previous.ControlPlaneOmitAvailabilityZone, &dst.ControlPlaneOmitAvailabilityZone)
211+
optional.RestoreBool(&previous.DisablePortSecurity, &dst.DisablePortSecurity)
209212
}
210213

211214
func Convert_v1alpha7_OpenStackClusterSpec_To_v1beta1_OpenStackClusterSpec(in *OpenStackClusterSpec, out *infrav1.OpenStackClusterSpec, s apiconversion.Scope) error {

api/v1alpha7/zz_generated.conversion.go

Lines changed: 24 additions & 8 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: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ type OpenStackClusterSpec struct {
6565
// If left empty, the network will have the default MTU defined in Openstack network service.
6666
// To use this field, the Openstack installation requires the net-mtu neutron API extension.
6767
// +optional
68-
NetworkMTU int `json:"networkMTU,omitempty"`
68+
NetworkMTU optional.Int `json:"networkMTU,omitempty"`
6969

7070
// ExternalRouterIPs is an array of externalIPs on the respective subnets.
7171
// This is necessary if the router needs a fixed ip in a specific subnet.
@@ -92,7 +92,7 @@ type OpenStackClusterSpec struct {
9292
// to an external network. This allows for the creation of clusters when connecting
9393
// to an external network is not possible or desirable, e.g. if using a provider network.
9494
// +optional
95-
DisableExternalNetwork bool `json:"disableExternalNetwork"`
95+
DisableExternalNetwork optional.Bool `json:"disableExternalNetwork,omitempty"`
9696

9797
// APIServerLoadBalancer configures the optional LoadBalancer for the APIServer.
9898
// It must be activated by setting `enabled: true`.
@@ -112,7 +112,7 @@ type OpenStackClusterSpec struct {
112112
// configuration to manage the VIP on the control plane machines, which falls outside of
113113
// the scope of this controller.
114114
// +optional
115-
DisableAPIServerFloatingIP bool `json:"disableAPIServerFloatingIP"`
115+
DisableAPIServerFloatingIP optional.Bool `json:"disableAPIServerFloatingIP,omitempty"`
116116

117117
// APIServerFloatingIP is the floatingIP which will be associated with the API server.
118118
// The floatingIP will be created if it does not already exist.
@@ -149,7 +149,8 @@ type OpenStackClusterSpec struct {
149149

150150
// DisablePortSecurity disables the port security of the network created for the
151151
// Kubernetes cluster, which also disables SecurityGroups
152-
DisablePortSecurity bool `json:"disablePortSecurity,omitempty"`
152+
// +optional
153+
DisablePortSecurity optional.Bool `json:"disablePortSecurity,omitempty"`
153154

154155
// Tags for all resources in cluster
155156
// +listType=set
@@ -165,9 +166,12 @@ type OpenStackClusterSpec struct {
165166
// +optional
166167
ControlPlaneAvailabilityZones []string `json:"controlPlaneAvailabilityZones,omitempty"`
167168

168-
// Indicates whether to omit the az for control plane nodes, allowing the Nova scheduler
169-
// to make a decision on which az to use based on other scheduling constraints
170-
ControlPlaneOmitAvailabilityZone bool `json:"controlPlaneOmitAvailabilityZone,omitempty"`
169+
// ControlPlaneOmitAvailabilityZone causes availability zone to be
170+
// omitted when creating control plane nodes, allowing the Nova
171+
// scheduler to make a decision on which availability zone to use based
172+
// on other scheduling constraints
173+
// +optional
174+
ControlPlaneOmitAvailabilityZone optional.Bool `json:"controlPlaneOmitAvailabilityZone,omitempty"`
171175

172176
// Bastion is the OpenStack instance to login the nodes
173177
//

api/v1beta1/zz_generated.deepcopy.go

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

0 commit comments

Comments
 (0)