Skip to content

Commit e2541be

Browse files
committed
Add Router field for use existing router
1 parent 8b57e0a commit e2541be

15 files changed

+166
-44
lines changed

api/v1alpha3/conversion_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ func TestFuzzyConversion(t *testing.T) {
233233
v1alpha7Cluster.Spec.APIServerFixedIP = ""
234234
v1alpha7Cluster.Spec.AllowAllInClusterTraffic = false
235235
v1alpha7Cluster.Spec.DisableAPIServerFloatingIP = false
236+
v1alpha7Cluster.Spec.Router = nil
236237
v1alpha7Cluster.Spec.APIServerLoadBalancer.AllowedCIDRs = nil
237238
v1alpha7Cluster.Spec.APIServerLoadBalancer.Provider = ""
238239
if v1alpha7Cluster.Spec.Bastion != nil {

api/v1alpha3/zz_generated.conversion.go

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

api/v1alpha4/conversion_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ func TestFuzzyConversion(t *testing.T) {
338338
v1alpha7Cluster.Spec.APIServerLoadBalancer.Provider = ""
339339

340340
v1alpha7Cluster.Spec.ControlPlaneOmitAvailabilityZone = false
341+
v1alpha7Cluster.Spec.Router = nil
341342

342343
if v1alpha7Cluster.Spec.Bastion != nil {
343344
v1alpha7Cluster.Spec.Bastion.Instance.Image = ""
@@ -418,6 +419,8 @@ func TestFuzzyConversion(t *testing.T) {
418419

419420
v1alpha7ClusterTemplate.Spec.Template.Spec.ControlPlaneOmitAvailabilityZone = false
420421

422+
v1alpha7ClusterTemplate.Spec.Template.Spec.Router = nil
423+
421424
if v1alpha7ClusterTemplate.Spec.Template.Spec.Bastion != nil {
422425
v1alpha7ClusterTemplate.Spec.Template.Spec.Bastion.Instance.Image = ""
423426
}

api/v1alpha4/zz_generated.conversion.go

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

api/v1alpha5/zz_generated.conversion.go

Lines changed: 1 addition & 0 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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func restorev1alpha6MachineSpec(previous *OpenStackMachineSpec, dst *OpenStackMa
9191
func restorev1alpha7ClusterSpec(previous *infrav1.OpenStackClusterSpec, dst *infrav1.OpenStackClusterSpec) {
9292
// APIServerLoadBalancer.Provider is new in v1alpha7
9393
dst.APIServerLoadBalancer.Provider = previous.APIServerLoadBalancer.Provider
94+
dst.Router = previous.Router
9495
}
9596

9697
var _ ctrlconversion.Convertible = &OpenStackCluster{}
@@ -257,3 +258,7 @@ func Convert_v1alpha7_APIServerLoadBalancer_To_v1alpha6_APIServerLoadBalancer(in
257258
// Provider have been added in v1alpha7 but have no equivalent in v1alpha6
258259
return autoConvert_v1alpha7_APIServerLoadBalancer_To_v1alpha6_APIServerLoadBalancer(in, out, s)
259260
}
261+
262+
func Convert_v1alpha7_OpenStackClusterSpec_To_v1alpha6_OpenStackClusterSpec(in *infrav1.OpenStackClusterSpec, out *OpenStackClusterSpec, s conversion.Scope) error {
263+
return autoConvert_v1alpha7_OpenStackClusterSpec_To_v1alpha6_OpenStackClusterSpec(in, out, s)
264+
}

api/v1alpha6/zz_generated.conversion.go

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

api/v1alpha7/filter_convert.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1alpha7
1818

1919
import (
20+
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers"
2021
"github.com/gophercloud/gophercloud/openstack/networking/v2/networks"
2122
"github.com/gophercloud/gophercloud/openstack/networking/v2/subnets"
2223
)
@@ -51,3 +52,16 @@ func (networkFilter NetworkFilter) ToListOpt() networks.ListOpts {
5152
NotTagsAny: networkFilter.NotTagsAny,
5253
}
5354
}
55+
56+
func (routerFilter RouterFilter) ToListOpt() routers.ListOpts {
57+
return routers.ListOpts{
58+
ID: routerFilter.ID,
59+
Name: routerFilter.Name,
60+
Description: routerFilter.Description,
61+
ProjectID: routerFilter.ProjectID,
62+
Tags: routerFilter.Tags,
63+
TagsAny: routerFilter.TagsAny,
64+
NotTags: routerFilter.NotTags,
65+
NotTagsAny: routerFilter.NotTagsAny,
66+
}
67+
}

api/v1alpha7/openstackcluster_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ type OpenStackClusterSpec struct {
3939
// If you leave this empty, no network will be created.
4040
NodeCIDR string `json:"nodeCidr,omitempty"`
4141

42+
// If NodeCIDR is set this option can be used to detect an existing router.
43+
// If specified, no new router will be created.
44+
// +optional
45+
Router *RouterFilter `json:"router,omitempty"`
46+
4247
// If NodeCIDR cannot be set this can be used to detect an existing network.
4348
Network NetworkFilter `json:"network,omitempty"`
4449

api/v1alpha7/types.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ type SubnetFilter struct {
104104
NotTagsAny string `json:"notTagsAny,omitempty"`
105105
}
106106

107+
type RouterFilter struct {
108+
ID string `json:"id,omitempty"`
109+
Name string `json:"name,omitempty"`
110+
Description string `json:"description,omitempty"`
111+
ProjectID string `json:"projectId,omitempty"`
112+
Tags string `json:"tags,omitempty"`
113+
TagsAny string `json:"tagsAny,omitempty"`
114+
NotTags string `json:"notTags,omitempty"`
115+
NotTagsAny string `json:"notTagsAny,omitempty"`
116+
}
117+
107118
type PortOpts struct {
108119
// Network is a query for an openstack network that the port will be created or discovered on.
109120
// This will fail if the query returns more than one network.

0 commit comments

Comments
 (0)