@@ -49,7 +49,7 @@ func TestConvertFrom(t *testing.T) {
49
49
Spec : OpenStackClusterSpec {},
50
50
ObjectMeta : metav1.ObjectMeta {
51
51
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}}" ,
53
53
},
54
54
},
55
55
},
@@ -64,7 +64,7 @@ func TestConvertFrom(t *testing.T) {
64
64
Spec : OpenStackClusterTemplateSpec {},
65
65
ObjectMeta : metav1.ObjectMeta {
66
66
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\" :{}}}}}" ,
68
68
},
69
69
},
70
70
},
@@ -109,3 +109,50 @@ func TestConvertFrom(t *testing.T) {
109
109
})
110
110
}
111
111
}
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