@@ -215,6 +215,24 @@ var _ = Describe("OpenStackCluster API validations", func() {
215
215
Expect (cluster .Spec .ControlPlaneEndpoint ).To (Equal (* infrav1Cluster .Spec .ControlPlaneEndpoint ), "Control plane endpoint should be restored" )
216
216
Expect (cluster .Spec .IdentityRef .Kind ).To (Equal ("FakeKind" ), "IdentityRef.Kind should be restored" )
217
217
})
218
+
219
+ It ("should not enable an explicitly disabled bastion when converting to v1beta1" , func () {
220
+ cluster .Spec .Bastion = & infrav1alpha7.Bastion {Enabled : false }
221
+ Expect (create (cluster )).To (Succeed (), "OpenStackCluster creation should succeed" )
222
+
223
+ // Fetch the infrav1 version of the cluster
224
+ infrav1Cluster := & infrav1.OpenStackCluster {}
225
+ Expect (k8sClient .Get (ctx , types.NamespacedName {Name : cluster .Name , Namespace : cluster .Namespace }, infrav1Cluster )).To (Succeed (), "OpenStackCluster fetch should succeed" )
226
+
227
+ infrav1Bastion := infrav1Cluster .Spec .Bastion
228
+
229
+ // NOTE(mdbooth): It may be reasonable to remove the
230
+ // bastion if it is disabled with no other properties.
231
+ // It would be reasonable to update the assertions
232
+ // accordingly if we did that.
233
+ Expect (infrav1Bastion ).ToNot (BeNil (), "Bastion should not have been removed" )
234
+ Expect (infrav1Bastion .Enabled ).To (Equal (ptr .To (false )), "Bastion should remain disabled" )
235
+ })
218
236
})
219
237
220
238
Context ("v1alpha6" , func () {
@@ -252,5 +270,23 @@ var _ = Describe("OpenStackCluster API validations", func() {
252
270
Expect (cluster .Spec .ControlPlaneEndpoint ).To (Equal (* infrav1Cluster .Spec .ControlPlaneEndpoint ), "Control plane endpoint should be restored" )
253
271
Expect (cluster .Spec .IdentityRef .Kind ).To (Equal ("FakeKind" ), "IdentityRef.Kind should be restored" )
254
272
})
273
+
274
+ It ("should not enable an explicitly disabled bastion when converting to v1beta1" , func () {
275
+ cluster .Spec .Bastion = & infrav1alpha6.Bastion {Enabled : false }
276
+ Expect (create (cluster )).To (Succeed (), "OpenStackCluster creation should succeed" )
277
+
278
+ // Fetch the infrav1 version of the cluster
279
+ infrav1Cluster := & infrav1.OpenStackCluster {}
280
+ Expect (k8sClient .Get (ctx , types.NamespacedName {Name : cluster .Name , Namespace : cluster .Namespace }, infrav1Cluster )).To (Succeed (), "OpenStackCluster fetch should succeed" )
281
+
282
+ infrav1Bastion := infrav1Cluster .Spec .Bastion
283
+
284
+ // NOTE(mdbooth): It may be reasonable to remove the
285
+ // bastion if it is disabled with no other properties.
286
+ // It would be reasonable to update the assertions
287
+ // accordingly if we did that.
288
+ Expect (infrav1Bastion ).ToNot (BeNil (), "Bastion should not have been removed" )
289
+ Expect (infrav1Bastion .Enabled ).To (Equal (ptr .To (false )), "Bastion should remain disabled" )
290
+ })
255
291
})
256
292
})
0 commit comments