Skip to content

Commit

Permalink
Merge pull request #1559 from shiftstack/subnetparam
Browse files Browse the repository at this point in the history
⚠️ Replace SubnetParam with SubnetFilter
  • Loading branch information
k8s-ci-robot authored May 19, 2023
2 parents b67b42a + a1de516 commit c115e74
Show file tree
Hide file tree
Showing 10 changed files with 194 additions and 179 deletions.
15 changes: 15 additions & 0 deletions api/v1alpha5/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,18 @@ func Convert_v1alpha7_SecurityGroupFilter_To_v1alpha5_SecurityGroupParam(in *inf
}
return nil
}

func Convert_v1alpha5_SubnetParam_To_v1alpha7_SubnetFilter(in *SubnetParam, out *infrav1.SubnetFilter, _ conversion.Scope) error {
*out = infrav1.SubnetFilter(in.Filter)
if in.UUID != "" {
out.ID = in.UUID
}
return nil
}

func Convert_v1alpha7_SubnetFilter_To_v1alpha5_SubnetParam(in *infrav1.SubnetFilter, out *SubnetParam, _ conversion.Scope) error {
out.Filter = SubnetFilter(*in)
out.UUID = in.ID

return nil
}
74 changes: 34 additions & 40 deletions api/v1alpha5/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions api/v1alpha6/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,22 @@ func restorev1alpha7ClusterSpec(previous *infrav1.OpenStackClusterSpec, dst *inf
}
}

func restorev1alpha6ClusterSpec(previous *OpenStackClusterSpec, dst *OpenStackClusterSpec) {
for i := range previous.ExternalRouterIPs {
dstIP := &dst.ExternalRouterIPs[i]
previousIP := &previous.ExternalRouterIPs[i]

// Subnet.Filter.ID was overwritten in up-conversion by Subnet.UUID
dstIP.Subnet.Filter.ID = previousIP.Subnet.Filter.ID

// If Subnet.UUID was previously unset, we overwrote it with the value of Subnet.Filter.ID
// Don't unset it again if it doesn't have the previous value of Subnet.Filter.ID, because that means it was genuinely changed
if previousIP.Subnet.UUID == "" && dstIP.Subnet.UUID == previousIP.Subnet.Filter.ID {
dstIP.Subnet.UUID = ""
}
}
}

var _ ctrlconversion.Convertible = &OpenStackCluster{}

func (r *OpenStackCluster) ConvertTo(dstRaw ctrlconversion.Hub) error {
Expand Down Expand Up @@ -156,6 +172,7 @@ func (r *OpenStackCluster) ConvertFrom(srcRaw ctrlconversion.Hub) error {
if prevBastion != nil {
restorev1alpha6MachineSpec(&prevBastion.Instance, &r.Spec.Bastion.Instance)
}
restorev1alpha6ClusterSpec(&previous.Spec, &r.Spec)
restorev1alpha6ClusterStatus(&previous.Status, &r.Status)
}

Expand Down Expand Up @@ -206,6 +223,7 @@ func (r *OpenStackClusterTemplate) ConvertFrom(srcRaw ctrlconversion.Hub) error
if prevBastion != nil {
restorev1alpha6MachineSpec(&prevBastion.Instance, &r.Spec.Template.Spec.Bastion.Instance)
}
restorev1alpha6ClusterSpec(&previous.Spec.Template.Spec, &r.Spec.Template.Spec)
}

return nil
Expand Down Expand Up @@ -477,3 +495,18 @@ func Convert_v1alpha7_SecurityGroupFilter_To_v1alpha6_SecurityGroupParam(in *inf
}
return nil
}

func Convert_v1alpha6_SubnetParam_To_v1alpha7_SubnetFilter(in *SubnetParam, out *infrav1.SubnetFilter, _ conversion.Scope) error {
*out = infrav1.SubnetFilter(in.Filter)
if in.UUID != "" {
out.ID = in.UUID
}
return nil
}

func Convert_v1alpha7_SubnetFilter_To_v1alpha6_SubnetParam(in *infrav1.SubnetFilter, out *SubnetParam, _ conversion.Scope) error {
out.Filter = SubnetFilter(*in)
out.UUID = in.ID

return nil
}
74 changes: 34 additions & 40 deletions api/v1alpha6/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 1 addition & 11 deletions api/v1alpha7/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type ExternalRouterIPParam struct {
// The FixedIP in the corresponding subnet
FixedIP string `json:"fixedIP,omitempty"`
// The subnet in which the FixedIP is used for the Gateway of this router
Subnet SubnetParam `json:"subnet"`
Subnet SubnetFilter `json:"subnet"`
}

type SecurityGroupFilter struct {
Expand Down Expand Up @@ -56,16 +56,6 @@ type NetworkFilter struct {
NotTagsAny string `json:"notTagsAny,omitempty"`
}

type SubnetParam struct {
// Optional UUID of the subnet.
// If specified this will not be validated prior to server creation.
// If specified, the enclosing `NetworkParam` must also be specified by UUID.
UUID string `json:"uuid,omitempty"`

// Filters for optional subnet query
Filter SubnetFilter `json:"filter,omitempty"`
}

type SubnetFilter struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Expand Down
16 changes: 0 additions & 16 deletions api/v1alpha7/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c115e74

Please sign in to comment.