@@ -22,6 +22,7 @@ import (
22
22
corev1 "k8s.io/api/core/v1"
23
23
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
24
24
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
25
+ "k8s.io/apimachinery/pkg/runtime/schema"
25
26
"sigs.k8s.io/controller-runtime/pkg/client"
26
27
27
28
addonsv1 "sigs.k8s.io/cluster-api/api/addons/v1beta2"
@@ -286,7 +287,7 @@ func addMachineDeploymentToObjectTree(ctx context.Context, c client.Client, clus
286
287
tree .Add (templateParent , machineTemplateRefObject , ObjectMetaName ("MachineInfrastructureTemplate" ))
287
288
}
288
289
289
- machineSets := selectMachinesSetsControlledBy (machineSetList , md )
290
+ machineSets := selectMachinesSetsControlledBy (machineSetList , md , clusterv1 . GroupVersion . WithKind ( "MachineDeployment" ). GroupKind () )
290
291
for i := range machineSets {
291
292
ms := machineSets [i ]
292
293
@@ -296,7 +297,7 @@ func addMachineDeploymentToObjectTree(ctx context.Context, c client.Client, clus
296
297
parent = ms
297
298
}
298
299
299
- machines := selectMachinesControlledBy (machinesList , ms )
300
+ machines := selectMachinesControlledBy (machinesList , ms , clusterv1 . GroupVersion . WithKind ( "MachineSet" ). GroupKind () )
300
301
for _ , w := range machines {
301
302
addMachineFunc (parent , w )
302
303
}
@@ -321,7 +322,7 @@ func addMachinePoolsToObjectTree(ctx context.Context, c client.Client, workers *
321
322
}
322
323
}
323
324
324
- machines := selectMachinesControlledBy (machinesList , mp )
325
+ machines := selectMachinesControlledBy (machinesList , mp , clusterv1 . GroupVersion . WithKind ( "MachinePool" ). GroupKind () )
325
326
for _ , m := range machines {
326
327
addMachineFunc (mp , m )
327
328
}
@@ -417,22 +418,22 @@ func selectControlPlaneMachines(machineList *clusterv1.MachineList) []*clusterv1
417
418
return machines
418
419
}
419
420
420
- func selectMachinesSetsControlledBy (machineSetList * clusterv1.MachineSetList , controller client.Object ) []* clusterv1.MachineSet {
421
+ func selectMachinesSetsControlledBy (machineSetList * clusterv1.MachineSetList , controller client.Object , controllerGK schema. GroupKind ) []* clusterv1.MachineSet {
421
422
machineSets := []* clusterv1.MachineSet {}
422
423
for i := range machineSetList .Items {
423
424
m := & machineSetList .Items [i ]
424
- if util .IsControlledBy (m , controller ) {
425
+ if util .IsControlledBy (m , controller , controllerGK ) {
425
426
machineSets = append (machineSets , m )
426
427
}
427
428
}
428
429
return machineSets
429
430
}
430
431
431
- func selectMachinesControlledBy (machineList * clusterv1.MachineList , controller client.Object ) []* clusterv1.Machine {
432
+ func selectMachinesControlledBy (machineList * clusterv1.MachineList , controller client.Object , controllerGK schema. GroupKind ) []* clusterv1.Machine {
432
433
machines := []* clusterv1.Machine {}
433
434
for i := range machineList .Items {
434
435
m := & machineList .Items [i ]
435
- if util .IsControlledBy (m , controller ) {
436
+ if util .IsControlledBy (m , controller , controllerGK ) {
436
437
machines = append (machines , m )
437
438
}
438
439
}
0 commit comments