Skip to content

Commit eeedb9d

Browse files
committed
WIP - AllNodes security groups API
1 parent 5786940 commit eeedb9d

17 files changed

+910
-85
lines changed

api/v1alpha5/conversion.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,3 +504,7 @@ func Convert_v1alpha8_OpenStackMachineStatus_To_v1alpha5_OpenStackMachineStatus(
504504
// ReferencedResources have no equivalent in v1alpha5
505505
return autoConvert_v1alpha8_OpenStackMachineStatus_To_v1alpha5_OpenStackMachineStatus(in, out, s)
506506
}
507+
508+
func Convert_v1alpha8_SecurityGroupRule_To_v1alpha5_SecurityGroupRule(in *infrav1.SecurityGroupRule, out *SecurityGroupRule, s conversion.Scope) error {
509+
return autoConvert_v1alpha8_SecurityGroupRule_To_v1alpha5_SecurityGroupRule(in, out, s)
510+
}

api/v1alpha5/conversion_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestConvertFrom(t *testing.T) {
4949
Spec: OpenStackClusterSpec{},
5050
ObjectMeta: metav1.ObjectMeta{
5151
Annotations: map[string]string{
52-
"cluster.x-k8s.io/conversion-data": "{\"spec\":{\"allowAllInClusterTraffic\":false,\"apiServerLoadBalancer\":{},\"cloudName\":\"\",\"controlPlaneEndpoint\":{\"host\":\"\",\"port\":0},\"disableAPIServerFloatingIP\":false,\"disableExternalNetwork\":false,\"externalNetwork\":{},\"managedSecurityGroups\":false,\"network\":{},\"subnet\":{}},\"status\":{\"ready\":false}}",
52+
"cluster.x-k8s.io/conversion-data": "{\"spec\":{\"allowAllInClusterTraffic\":false,\"apiServerLoadBalancer\":{},\"cloudName\":\"\",\"controlPlaneEndpoint\":{\"host\":\"\",\"port\":0},\"disableAPIServerFloatingIP\":false,\"disableExternalNetwork\":false,\"externalNetwork\":{},\"network\":{},\"subnet\":{}},\"status\":{\"ready\":false}}",
5353
},
5454
},
5555
},
@@ -64,7 +64,7 @@ func TestConvertFrom(t *testing.T) {
6464
Spec: OpenStackClusterTemplateSpec{},
6565
ObjectMeta: metav1.ObjectMeta{
6666
Annotations: map[string]string{
67-
"cluster.x-k8s.io/conversion-data": "{\"spec\":{\"template\":{\"spec\":{\"allowAllInClusterTraffic\":false,\"apiServerLoadBalancer\":{},\"cloudName\":\"\",\"controlPlaneEndpoint\":{\"host\":\"\",\"port\":0},\"disableAPIServerFloatingIP\":false,\"disableExternalNetwork\":false,\"externalNetwork\":{},\"managedSecurityGroups\":false,\"network\":{},\"subnet\":{}}}}}",
67+
"cluster.x-k8s.io/conversion-data": "{\"spec\":{\"template\":{\"spec\":{\"allowAllInClusterTraffic\":false,\"apiServerLoadBalancer\":{},\"cloudName\":\"\",\"controlPlaneEndpoint\":{\"host\":\"\",\"port\":0},\"disableAPIServerFloatingIP\":false,\"disableExternalNetwork\":false,\"externalNetwork\":{},\"network\":{},\"subnet\":{}}}}}",
6868
},
6969
},
7070
},

api/v1alpha5/zz_generated.conversion.go

Lines changed: 80 additions & 15 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
@@ -82,6 +82,10 @@ func restorev1alpha8ClusterStatus(previous *infrav1.OpenStackClusterStatus, dst
8282
if previous.Bastion != nil {
8383
dst.Bastion.ReferencedResources = previous.Bastion.ReferencedResources
8484
}
85+
86+
if previous.AllNodesSecurityGroup != nil {
87+
dst.AllNodesSecurityGroup = previous.AllNodesSecurityGroup
88+
}
8589
}
8690

8791
func restorev1alpha6ClusterSpec(previous *OpenStackClusterSpec, dst *OpenStackClusterSpec) {
@@ -124,6 +128,11 @@ var v1alpha6OpenStackClusterRestorer = conversion.RestorerFor[*OpenStackCluster]
124128
}
125129

126130
var v1alpha8OpenStackClusterRestorer = conversion.RestorerFor[*infrav1.OpenStackCluster]{
131+
"managedSecurityGroups": conversion.UnconditionalFieldRestorer(
132+
func(c *infrav1.OpenStackCluster) **infrav1.SecurityGroupsSpec {
133+
return &c.Spec.ManagedSecurityGroups
134+
},
135+
),
127136
"externalNetwork": conversion.UnconditionalFieldRestorer(
128137
func(c *infrav1.OpenStackCluster) *infrav1.NetworkFilter {
129138
return &c.Spec.ExternalNetwork
@@ -204,6 +213,11 @@ var v1alpha6OpenStackClusterTemplateRestorer = conversion.RestorerFor[*OpenStack
204213
}
205214

206215
var v1alpha8OpenStackClusterTemplateRestorer = conversion.RestorerFor[*infrav1.OpenStackClusterTemplate]{
216+
"managedSecurityGroups": conversion.UnconditionalFieldRestorer(
217+
func(c *infrav1.OpenStackClusterTemplate) **infrav1.SecurityGroupsSpec {
218+
return &c.Spec.Template.Spec.ManagedSecurityGroups
219+
},
220+
),
207221
"externalNetwork": conversion.UnconditionalFieldRestorer(
208222
func(c *infrav1.OpenStackClusterTemplate) *infrav1.NetworkFilter {
209223
return &c.Spec.Template.Spec.ExternalNetwork
@@ -482,6 +496,10 @@ func Convert_v1alpha8_OpenStackClusterSpec_To_v1alpha6_OpenStackClusterSpec(in *
482496
out.ExternalNetworkID = in.ExternalNetwork.ID
483497
}
484498

499+
if in.ManagedSecurityGroups != nil && in.ManagedSecurityGroups.Enabled {
500+
out.ManagedSecurityGroups = true
501+
}
502+
485503
return nil
486504
}
487505

@@ -497,6 +515,12 @@ func Convert_v1alpha6_OpenStackClusterSpec_To_v1alpha8_OpenStackClusterSpec(in *
497515
}
498516
}
499517

518+
if in.ManagedSecurityGroups {
519+
out.ManagedSecurityGroups = &infrav1.SecurityGroupsSpec{
520+
Enabled: true,
521+
}
522+
}
523+
500524
return nil
501525
}
502526

@@ -774,3 +798,12 @@ func Convert_v1alpha8_Bastion_To_v1alpha6_Bastion(in *infrav1.Bastion, out *Bast
774798

775799
return nil
776800
}
801+
802+
func Convert_v1alpha8_SecurityGroupRule_To_v1alpha6_SecurityGroupRule(in *infrav1.SecurityGroupRule, out *SecurityGroupRule, s apiconversion.Scope) error {
803+
err := autoConvert_v1alpha8_SecurityGroupRule_To_v1alpha6_SecurityGroupRule(in, out, s)
804+
if err != nil {
805+
return err
806+
}
807+
808+
return nil
809+
}

api/v1alpha6/zz_generated.conversion.go

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

0 commit comments

Comments
 (0)