Skip to content

Commit ebb6cc6

Browse files
committed
WIP - AllNodes security groups API
1 parent 47b87c8 commit ebb6cc6

17 files changed

+925
-85
lines changed

api/v1alpha5/conversion.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,3 +522,7 @@ func Convert_v1alpha5_Bastion_To_v1alpha8_Bastion(in *Bastion, out *infrav1.Bast
522522
in.Instance.FloatingIP = out.FloatingIP
523523
return nil
524524
}
525+
526+
func Convert_v1alpha8_SecurityGroupRule_To_v1alpha5_SecurityGroupRule(in *infrav1.SecurityGroupRule, out *SecurityGroupRule, s conversion.Scope) error {
527+
return autoConvert_v1alpha8_SecurityGroupRule_To_v1alpha5_SecurityGroupRule(in, out, s)
528+
}

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
@@ -86,6 +86,10 @@ func restorev1alpha8ClusterStatus(previous *infrav1.OpenStackClusterStatus, dst
8686
if previous.Bastion != nil {
8787
dst.Bastion.ReferencedResources = previous.Bastion.ReferencedResources
8888
}
89+
90+
if previous.AllNodesSecurityGroup != nil {
91+
dst.AllNodesSecurityGroup = previous.AllNodesSecurityGroup
92+
}
8993
}
9094

9195
func restorev1alpha6ClusterSpec(previous *OpenStackClusterSpec, dst *OpenStackClusterSpec) {
@@ -128,6 +132,11 @@ var v1alpha6OpenStackClusterRestorer = conversion.RestorerFor[*OpenStackCluster]
128132
}
129133

130134
var v1alpha8OpenStackClusterRestorer = conversion.RestorerFor[*infrav1.OpenStackCluster]{
135+
"managedSecurityGroups": conversion.UnconditionalFieldRestorer(
136+
func(c *infrav1.OpenStackCluster) **infrav1.SecurityGroupsSpec {
137+
return &c.Spec.ManagedSecurityGroups
138+
},
139+
),
131140
"externalNetwork": conversion.UnconditionalFieldRestorer(
132141
func(c *infrav1.OpenStackCluster) *infrav1.NetworkFilter {
133142
return &c.Spec.ExternalNetwork
@@ -208,6 +217,11 @@ var v1alpha6OpenStackClusterTemplateRestorer = conversion.RestorerFor[*OpenStack
208217
}
209218

210219
var v1alpha8OpenStackClusterTemplateRestorer = conversion.RestorerFor[*infrav1.OpenStackClusterTemplate]{
220+
"managedSecurityGroups": conversion.UnconditionalFieldRestorer(
221+
func(c *infrav1.OpenStackClusterTemplate) **infrav1.SecurityGroupsSpec {
222+
return &c.Spec.Template.Spec.ManagedSecurityGroups
223+
},
224+
),
211225
"externalNetwork": conversion.UnconditionalFieldRestorer(
212226
func(c *infrav1.OpenStackClusterTemplate) *infrav1.NetworkFilter {
213227
return &c.Spec.Template.Spec.ExternalNetwork
@@ -486,6 +500,10 @@ func Convert_v1alpha8_OpenStackClusterSpec_To_v1alpha6_OpenStackClusterSpec(in *
486500
out.ExternalNetworkID = in.ExternalNetwork.ID
487501
}
488502

503+
if in.ManagedSecurityGroups != nil && in.ManagedSecurityGroups.Enabled {
504+
out.ManagedSecurityGroups = true
505+
}
506+
489507
return nil
490508
}
491509

@@ -501,6 +519,12 @@ func Convert_v1alpha6_OpenStackClusterSpec_To_v1alpha8_OpenStackClusterSpec(in *
501519
}
502520
}
503521

522+
if in.ManagedSecurityGroups {
523+
out.ManagedSecurityGroups = &infrav1.SecurityGroupsSpec{
524+
Enabled: true,
525+
}
526+
}
527+
504528
return nil
505529
}
506530

@@ -780,3 +804,12 @@ func Convert_v1alpha8_Bastion_To_v1alpha6_Bastion(in *infrav1.Bastion, out *Bast
780804
out.Instance.FloatingIP = in.FloatingIP
781805
return nil
782806
}
807+
808+
func Convert_v1alpha8_SecurityGroupRule_To_v1alpha6_SecurityGroupRule(in *infrav1.SecurityGroupRule, out *SecurityGroupRule, s apiconversion.Scope) error {
809+
err := autoConvert_v1alpha8_SecurityGroupRule_To_v1alpha6_SecurityGroupRule(in, out, s)
810+
if err != nil {
811+
return err
812+
}
813+
814+
return nil
815+
}

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)