Skip to content

Commit 4b63333

Browse files
committed
Replace SubnetParam with SubnetFilter
1 parent b67b42a commit 4b63333

File tree

9 files changed

+169
-179
lines changed

9 files changed

+169
-179
lines changed

api/v1alpha5/conversion.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,3 +296,18 @@ func Convert_v1alpha7_SecurityGroupFilter_To_v1alpha5_SecurityGroupParam(in *inf
296296
}
297297
return nil
298298
}
299+
300+
func Convert_v1alpha5_SubnetParam_To_v1alpha7_SubnetFilter(in *SubnetParam, out *infrav1.SubnetFilter, _ conversion.Scope) error {
301+
*out = infrav1.SubnetFilter(in.Filter)
302+
if in.UUID != "" {
303+
out.ID = in.UUID
304+
}
305+
return nil
306+
}
307+
308+
func Convert_v1alpha7_SubnetFilter_To_v1alpha5_SubnetParam(in *infrav1.SubnetFilter, out *SubnetParam, _ conversion.Scope) error {
309+
out.Filter = SubnetFilter(*in)
310+
out.UUID = in.ID
311+
312+
return nil
313+
}

api/v1alpha5/zz_generated.conversion.go

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

api/v1alpha6/conversion.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,22 @@ func restorev1alpha7ClusterSpec(previous *infrav1.OpenStackClusterSpec, dst *inf
126126
}
127127
}
128128

129+
func restorev1alpha6ClusterSpec(previous *OpenStackClusterSpec, dst *OpenStackClusterSpec) {
130+
for i := range previous.ExternalRouterIPs {
131+
dstIP := &dst.ExternalRouterIPs[i]
132+
previousIP := &previous.ExternalRouterIPs[i]
133+
134+
// Subnet.Filter.ID was overwritten in up-conversion by Subnet.UUID
135+
dstIP.Subnet.Filter.ID = previousIP.Subnet.Filter.ID
136+
137+
// If Subnet.UUID was previously unset, we overwrote it with the value of Subnet.Filter.ID
138+
// Don't unset it again if it doesn't have the previous value of Subnet.Filter.ID, because that means it was genuinely changed
139+
if previousIP.Subnet.UUID == "" && dstIP.Subnet.UUID == previousIP.Subnet.Filter.ID {
140+
dstIP.Subnet.UUID = ""
141+
}
142+
}
143+
}
144+
129145
var _ ctrlconversion.Convertible = &OpenStackCluster{}
130146

131147
func (r *OpenStackCluster) ConvertTo(dstRaw ctrlconversion.Hub) error {
@@ -156,6 +172,7 @@ func (r *OpenStackCluster) ConvertFrom(srcRaw ctrlconversion.Hub) error {
156172
if prevBastion != nil {
157173
restorev1alpha6MachineSpec(&prevBastion.Instance, &r.Spec.Bastion.Instance)
158174
}
175+
restorev1alpha6ClusterSpec(&previous.Spec, &r.Spec)
159176
restorev1alpha6ClusterStatus(&previous.Status, &r.Status)
160177
}
161178

@@ -206,6 +223,7 @@ func (r *OpenStackClusterTemplate) ConvertFrom(srcRaw ctrlconversion.Hub) error
206223
if prevBastion != nil {
207224
restorev1alpha6MachineSpec(&prevBastion.Instance, &r.Spec.Template.Spec.Bastion.Instance)
208225
}
226+
restorev1alpha6ClusterSpec(&previous.Spec.Template.Spec, &r.Spec.Template.Spec)
209227
}
210228

211229
return nil
@@ -477,3 +495,18 @@ func Convert_v1alpha7_SecurityGroupFilter_To_v1alpha6_SecurityGroupParam(in *inf
477495
}
478496
return nil
479497
}
498+
499+
func Convert_v1alpha6_SubnetParam_To_v1alpha7_SubnetFilter(in *SubnetParam, out *infrav1.SubnetFilter, _ conversion.Scope) error {
500+
*out = infrav1.SubnetFilter(in.Filter)
501+
if in.UUID != "" {
502+
out.ID = in.UUID
503+
}
504+
return nil
505+
}
506+
507+
func Convert_v1alpha7_SubnetFilter_To_v1alpha6_SubnetParam(in *infrav1.SubnetFilter, out *SubnetParam, _ conversion.Scope) error {
508+
out.Filter = SubnetFilter(*in)
509+
out.UUID = in.ID
510+
511+
return nil
512+
}

api/v1alpha6/zz_generated.conversion.go

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

api/v1alpha7/types.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type ExternalRouterIPParam struct {
2626
// The FixedIP in the corresponding subnet
2727
FixedIP string `json:"fixedIP,omitempty"`
2828
// The subnet in which the FixedIP is used for the Gateway of this router
29-
Subnet SubnetParam `json:"subnet"`
29+
Subnet SubnetFilter `json:"subnet"`
3030
}
3131

3232
type SecurityGroupFilter struct {
@@ -56,16 +56,6 @@ type NetworkFilter struct {
5656
NotTagsAny string `json:"notTagsAny,omitempty"`
5757
}
5858

59-
type SubnetParam struct {
60-
// Optional UUID of the subnet.
61-
// If specified this will not be validated prior to server creation.
62-
// If specified, the enclosing `NetworkParam` must also be specified by UUID.
63-
UUID string `json:"uuid,omitempty"`
64-
65-
// Filters for optional subnet query
66-
Filter SubnetFilter `json:"filter,omitempty"`
67-
}
68-
6959
type SubnetFilter struct {
7060
Name string `json:"name,omitempty"`
7161
Description string `json:"description,omitempty"`

api/v1alpha7/zz_generated.deepcopy.go

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

0 commit comments

Comments
 (0)