@@ -248,6 +248,54 @@ var moveTests = []struct {
248
248
},
249
249
wantErr : false ,
250
250
},
251
+ {
252
+ name : "Cluster with MachineDeployment with a static bootstrap config" ,
253
+ fields : moveTestsFields {
254
+ objs : test .NewFakeCluster ("ns1" , "cluster1" ).
255
+ WithMachineDeployments (
256
+ test .NewFakeMachineDeployment ("md1" ).
257
+ WithStaticBootstrapConfig ().
258
+ WithMachineSets (
259
+ test .NewFakeMachineSet ("ms1" ).
260
+ WithStaticBootstrapConfig ().
261
+ WithMachines (
262
+ test .NewFakeMachine ("m1" ).
263
+ WithStaticBootstrapConfig (),
264
+ test .NewFakeMachine ("m2" ).
265
+ WithStaticBootstrapConfig (),
266
+ ),
267
+ ),
268
+ ).Objs (),
269
+ },
270
+ wantMoveGroups : [][]string {
271
+ { // group 1
272
+ "cluster.x-k8s.io/v1beta1, Kind=Cluster, ns1/cluster1" ,
273
+ },
274
+ { // group 2 (objects with ownerReferences in group 1)
275
+ // owned by Clusters
276
+ "/v1, Kind=Secret, ns1/cluster1-ca" ,
277
+ "/v1, Kind=Secret, ns1/cluster1-kubeconfig" ,
278
+ "cluster.x-k8s.io/v1beta1, Kind=MachineDeployment, ns1/md1" ,
279
+ "infrastructure.cluster.x-k8s.io/v1beta1, Kind=GenericInfrastructureCluster, ns1/cluster1" ,
280
+ "infrastructure.cluster.x-k8s.io/v1beta1, Kind=GenericInfrastructureMachineTemplate, ns1/md1" ,
281
+ },
282
+ { // group 3 (objects with ownerReferences in group 1,2)
283
+ // owned by MachineDeployments
284
+ "cluster.x-k8s.io/v1beta1, Kind=MachineSet, ns1/ms1" ,
285
+ },
286
+ { // group 4 (objects with ownerReferences in group 1,2,3)
287
+ // owned by MachineSets
288
+ "cluster.x-k8s.io/v1beta1, Kind=Machine, ns1/m1" ,
289
+ "cluster.x-k8s.io/v1beta1, Kind=Machine, ns1/m2" ,
290
+ },
291
+ { // group 5 (objects with ownerReferences in group 1,2,3,4)
292
+ // owned by Machines
293
+ "infrastructure.cluster.x-k8s.io/v1beta1, Kind=GenericInfrastructureMachine, ns1/m1" ,
294
+ "infrastructure.cluster.x-k8s.io/v1beta1, Kind=GenericInfrastructureMachine, ns1/m2" ,
295
+ },
296
+ },
297
+ wantErr : false ,
298
+ },
251
299
{
252
300
name : "Cluster with Control Plane" ,
253
301
fields : moveTestsFields {
@@ -825,7 +873,7 @@ func Test_objectMover_restoreTargetObject(t *testing.T) {
825
873
oTo .SetKind (node .identity .Kind )
826
874
827
875
if err := csTo .Get (ctx , key , oTo ); err != nil {
828
- t .Errorf ("error = %v when checking for %v created in target cluster" , err , key )
876
+ t .Errorf ("error = %v when checking for %s % v created in target cluster" , err , oTo . GetKind () , key )
829
877
continue
830
878
}
831
879
@@ -853,7 +901,7 @@ func Test_objectMover_restoreTargetObject(t *testing.T) {
853
901
oAfter .SetKind (node .identity .Kind )
854
902
855
903
if err := csAfter .Get (ctx , keyAfter , oAfter ); err != nil {
856
- t .Errorf ("error = %v when checking for %v created in target cluster" , err , key )
904
+ t .Errorf ("error = %v when checking for %s % v created in target cluster" , err , oAfter . GetKind () , key )
857
905
continue
858
906
}
859
907
@@ -1076,7 +1124,7 @@ func Test_objectMover_fromDirectory(t *testing.T) {
1076
1124
oTo .SetKind (node .identity .Kind )
1077
1125
1078
1126
if err := csTo .Get (ctx , key , oTo ); err != nil {
1079
- t .Errorf ("error = %v when checking for %v created in target cluster" , err , key )
1127
+ t .Errorf ("error = %v when checking for %s % v created in target cluster" , err , oTo . GetKind () , key )
1080
1128
continue
1081
1129
}
1082
1130
}
@@ -1164,7 +1212,7 @@ func Test_objectMover_move_dryRun(t *testing.T) {
1164
1212
oFrom .SetKind (node .identity .Kind )
1165
1213
1166
1214
if err := csFrom .Get (ctx , key , oFrom ); err != nil {
1167
- t .Errorf ("error = %v when checking for %v kept in source cluster" , err , key )
1215
+ t .Errorf ("error = %v when checking for %s % v kept in source cluster" , err , oFrom . GetKind () , key )
1168
1216
continue
1169
1217
}
1170
1218
@@ -1176,11 +1224,11 @@ func Test_objectMover_move_dryRun(t *testing.T) {
1176
1224
err := csTo .Get (ctx , key , oTo )
1177
1225
if err == nil {
1178
1226
if oFrom .GetNamespace () != "" {
1179
- t .Errorf ("%v created in target cluster which should not" , key )
1227
+ t .Errorf ("%s % v created in target cluster which should not" , oFrom . GetKind () , key )
1180
1228
continue
1181
1229
}
1182
1230
} else if ! apierrors .IsNotFound (err ) {
1183
- t .Errorf ("error = %v when checking for %v should not created ojects in target cluster" , err , key )
1231
+ t .Errorf ("error = %v when checking for %s % v should not created ojects in target cluster" , err , oFrom . GetKind () , key )
1184
1232
continue
1185
1233
}
1186
1234
}
@@ -1240,11 +1288,11 @@ func Test_objectMover_move(t *testing.T) {
1240
1288
err := csFrom .Get (ctx , key , oFrom )
1241
1289
if err == nil {
1242
1290
if ! node .isGlobal && ! node .isGlobalHierarchy {
1243
- t .Errorf ("%v not deleted in source cluster" , key )
1291
+ t .Errorf ("%s % v not deleted in source cluster" , oFrom . GetKind () , key )
1244
1292
continue
1245
1293
}
1246
1294
} else if ! apierrors .IsNotFound (err ) {
1247
- t .Errorf ("error = %v when checking for %v deleted in source cluster" , err , key )
1295
+ t .Errorf ("error = %v when checking for %s % v deleted in source cluster" , err , oFrom . GetKind () , key )
1248
1296
continue
1249
1297
}
1250
1298
@@ -1254,7 +1302,7 @@ func Test_objectMover_move(t *testing.T) {
1254
1302
oTo .SetKind (node .identity .Kind )
1255
1303
1256
1304
if err := csTo .Get (ctx , key , oTo ); err != nil {
1257
- t .Errorf ("error = %v when checking for %v created in target cluster" , err , key )
1305
+ t .Errorf ("error = %v when checking for %s % v created in target cluster" , err , oFrom . GetKind () , key )
1258
1306
continue
1259
1307
}
1260
1308
}
@@ -1349,11 +1397,11 @@ func Test_objectMover_move_with_Mutator(t *testing.T) {
1349
1397
err := csFrom .Get (ctx , key , oFrom )
1350
1398
if err == nil {
1351
1399
if ! node .isGlobal && ! node .isGlobalHierarchy {
1352
- t .Errorf ("%v not deleted in source cluster" , key )
1400
+ t .Errorf ("%s % v not deleted in source cluster" , oFrom . GetKind () , key )
1353
1401
continue
1354
1402
}
1355
1403
} else if ! apierrors .IsNotFound (err ) {
1356
- t .Errorf ("error = %v when checking for %v deleted in source cluster" , err , key )
1404
+ t .Errorf ("error = %v when checking for %s % v deleted in source cluster" , err , oFrom . GetKind () , key )
1357
1405
continue
1358
1406
}
1359
1407
@@ -1366,7 +1414,7 @@ func Test_objectMover_move_with_Mutator(t *testing.T) {
1366
1414
}
1367
1415
1368
1416
if err := csTo .Get (ctx , key , oTo ); err != nil {
1369
- t .Errorf ("error = %v when checking for %v created in target cluster" , err , key )
1417
+ t .Errorf ("error = %v when checking for %s % v created in target cluster" , err , oFrom . GetKind () , key )
1370
1418
continue
1371
1419
}
1372
1420
if fields , knownKind := updateKnownKinds [oTo .GetKind ()]; knownKind {
0 commit comments