in controllers/helpers.go [32:62]
func (r *EtcdadmConfigReconciler) ClusterToEtcdadmConfigs(ctx context.Context, o client.Object) []ctrl.Request {
var result []ctrl.Request
c, ok := o.(*clusterv1.Cluster)
if !ok {
r.Log.Error(errors.Errorf("expected a Cluster but got a %T", o.GetObjectKind()), "failed to get EtcdadmConfigs for Cluster")
return nil
}
selectors := []client.ListOption{
client.InNamespace(c.Namespace),
client.MatchingLabels{
clusterv1.ClusterNameLabel: c.Name,
},
}
machineList := &clusterv1.MachineList{}
if err := r.Client.List(ctx, machineList, selectors...); err != nil {
r.Log.Error(err, "failed to list Machines", "Cluster", c.Name, "Namespace", c.Namespace)
return nil
}
for _, m := range machineList.Items {
if m.Spec.Bootstrap.ConfigRef != nil &&
m.Spec.Bootstrap.ConfigRef.GroupVersionKind().GroupKind() == etcdbootstrapv1.GroupVersion.WithKind("EtcdadmConfig").GroupKind() {
name := client.ObjectKey{Namespace: m.Namespace, Name: m.Spec.Bootstrap.ConfigRef.Name}
result = append(result, ctrl.Request{NamespacedName: name})
}
}
return result
}