@@ -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\" :{}},\" status\" :{\" ready\" :false}}" ,
52+ "cluster.x-k8s.io/conversion-data" : "{\" spec\" :{\" allowAllInClusterTraffic\" :false,\" apiServerLoadBalancer\" :{},\" cloudName\" :\" \" ,\" controlPlaneEndpoint\" :{\" host\" :\" \" ,\" port\" :0},\" disableAPIServerFloatingIP\" :false,\" disableExternalNetwork\" :false,\" externalNetwork\" :{},\" managedSecurityGroups\" :null ,\" network\" :{}},\" 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\" :{}}}}}" ,
67+ "cluster.x-k8s.io/conversion-data" : "{\" spec\" :{\" template\" :{\" spec\" :{\" allowAllInClusterTraffic\" :false,\" apiServerLoadBalancer\" :{},\" cloudName\" :\" \" ,\" controlPlaneEndpoint\" :{\" host\" :\" \" ,\" port\" :0},\" disableAPIServerFloatingIP\" :false,\" disableExternalNetwork\" :false,\" externalNetwork\" :{},\" managedSecurityGroups\" :null ,\" network\" :{}}}}}" ,
6868 },
6969 },
7070 },
@@ -109,3 +109,50 @@ func TestConvertFrom(t *testing.T) {
109109 })
110110 }
111111}
112+
113+ func TestConvert_v1alpha5_OpenStackClusterSpec_To_v1alpha8_OpenStackClusterSpec (t * testing.T ) {
114+ tests := []struct {
115+ name string
116+ in * OpenStackClusterSpec
117+ expectedOut * infrav1.OpenStackClusterSpec
118+ }{
119+ {
120+ name : "empty" ,
121+ in : & OpenStackClusterSpec {},
122+ expectedOut : & infrav1.OpenStackClusterSpec {},
123+ },
124+ {
125+ name : "with managed security groups and not allow all in cluster traffic" ,
126+ in : & OpenStackClusterSpec {
127+ ManagedSecurityGroups : true ,
128+ AllowAllInClusterTraffic : false ,
129+ },
130+ expectedOut : & infrav1.OpenStackClusterSpec {
131+ ManagedSecurityGroups : & infrav1.ManagedSecurityGroups {
132+ AllNodesSecurityGroupRules : infrav1 .LegacyCalicoSecurityGroupRules (),
133+ },
134+ },
135+ },
136+ {
137+ name : "with managed security groups and allow all in cluster traffic" ,
138+ in : & OpenStackClusterSpec {
139+ ManagedSecurityGroups : true ,
140+ AllowAllInClusterTraffic : true ,
141+ },
142+ expectedOut : & infrav1.OpenStackClusterSpec {
143+ ManagedSecurityGroups : & infrav1.ManagedSecurityGroups {},
144+ AllowAllInClusterTraffic : true ,
145+ },
146+ },
147+ }
148+
149+ for _ , tt := range tests {
150+ t .Run (tt .name , func (t * testing.T ) {
151+ g := gomega .NewWithT (t )
152+ out := & infrav1.OpenStackClusterSpec {}
153+ err := Convert_v1alpha5_OpenStackClusterSpec_To_v1alpha8_OpenStackClusterSpec (tt .in , out , nil )
154+ g .Expect (err ).NotTo (gomega .HaveOccurred ())
155+ g .Expect (out ).To (gomega .Equal (tt .expectedOut ))
156+ })
157+ }
158+ }
0 commit comments