@@ -514,7 +514,7 @@ var _ = Describe("webhooks validator", func() {
514
514
NonRoot : ptr .To (false ),
515
515
EnableCommonBootImageImport : ptr .To (true ),
516
516
EnableManagedTenantQuota : ptr .To (false ),
517
- }, "enableManagedTenantQuota" , "nonRoot" ),
517
+ }, "enableManagedTenantQuota" , "nonRoot" , "enableCommonBootImageImport" ),
518
518
)
519
519
})
520
520
})
@@ -1181,9 +1181,47 @@ var _ = Describe("webhooks validator", func() {
1181
1181
NonRoot : ptr .To (false ),
1182
1182
EnableCommonBootImageImport : ptr .To (true ),
1183
1183
EnableManagedTenantQuota : ptr .To (false ),
1184
- }, "enableManagedTenantQuota" , "nonRoot" ),
1184
+ }, "enableManagedTenantQuota" , "nonRoot" , "enableCommonBootImageImport" ),
1185
+ )
1186
+ })
1187
+
1188
+ Context ("validate moved FG on update" , func () {
1189
+ DescribeTable ("should return warning for enableCommonBootImageImport on update" , func (newFG , oldFG * bool ) {
1190
+ newHCO := hco .DeepCopy ()
1191
+ hco .Spec .FeatureGates .EnableCommonBootImageImport = newFG
1192
+ newHCO .Spec .FeatureGates .EnableCommonBootImageImport = oldFG
1193
+
1194
+ err := wh .ValidateUpdate (ctx , dryRun , newHCO , hco )
1195
+
1196
+ Expect (err ).To (HaveOccurred ())
1197
+ expected := & ValidationWarning {}
1198
+ Expect (errors .As (err , & expected )).To (BeTrue ())
1199
+
1200
+ Expect (expected .warnings ).To (HaveLen (1 ))
1201
+ Expect (expected .warnings ).To (ContainElements (ContainSubstring ("enableCommonBootImageImport" )))
1202
+ },
1203
+ Entry ("should trigger warning if enableCommonBootImageImport appeared as true" , nil , ptr .To (true )),
1204
+ Entry ("should trigger warning if enableCommonBootImageImport appeared as false" , nil , ptr .To (false )),
1205
+ Entry ("should trigger warning if enableCommonBootImageImport has changed from true to false" , ptr .To (true ), ptr .To (false )),
1206
+ Entry ("should trigger warning if enableCommonBootImageImport has changed from false to true" , ptr .To (false ), ptr .To (true )),
1207
+ )
1208
+
1209
+ DescribeTable ("should not return warning for enableCommonBootImageImport if not change" , func (newFG , oldFG * bool ) {
1210
+ cli := getFakeClient (hco )
1211
+ wh := NewWebhookHandler (logger , cli , decoder , HcoValidNamespace , true , nil )
1212
+ newHCO := hco .DeepCopy ()
1213
+ hco .Spec .FeatureGates .EnableCommonBootImageImport = newFG
1214
+ newHCO .Spec .FeatureGates .EnableCommonBootImageImport = oldFG
1215
+
1216
+ Expect (wh .ValidateUpdate (ctx , dryRun , newHCO , hco )).To (Succeed ())
1217
+ },
1218
+ Entry ("should not trigger warning if enableCommonBootImageImport (true) disappeared" , ptr .To (true ), nil ),
1219
+ Entry ("should not trigger warning if enableCommonBootImageImport (false) disappeared" , ptr .To (false ), nil ),
1220
+ Entry ("should not trigger warning if enableCommonBootImageImport (true) wasn't changed" , ptr .To (true ), ptr .To (true )),
1221
+ Entry ("should not trigger warning if enableCommonBootImageImport (false) wasn't changed" , ptr .To (false ), ptr .To (false )),
1185
1222
)
1186
1223
})
1224
+
1187
1225
})
1188
1226
1189
1227
Context ("validate delete validation webhook" , func () {
0 commit comments