@@ -467,56 +467,6 @@ func (k KubeAwareAPIVersions) Less(i, j int) bool {
467
467
return k8sversion .CompareKubeAwareVersionStrings (k [i ], k [j ]) < 0
468
468
}
469
469
470
- // ClusterToObjectsMapper returns a mapper function that gets a cluster and lists all objects for the object passed in
471
- // and returns a list of requests.
472
- // NB: The objects are required to have `clusterv1.ClusterNameLabel` applied.
473
- //
474
- // Deprecated: This function is deprecated and will be removed in a future release, use ClusterToTypedObjectsMapper instead.
475
- // The problem with this function is that it uses UnstructuredList to retrieve objects, with the default client configuration
476
- // this will lead to uncached List calls, which is a major performance issue.
477
- func ClusterToObjectsMapper (c client.Client , ro client.ObjectList , scheme * runtime.Scheme ) (handler.MapFunc , error ) {
478
- gvk , err := apiutil .GVKForObject (ro , scheme )
479
- if err != nil {
480
- return nil , err
481
- }
482
-
483
- isNamespaced , err := isAPINamespaced (gvk , c .RESTMapper ())
484
- if err != nil {
485
- return nil , err
486
- }
487
-
488
- return func (ctx context.Context , o client.Object ) []ctrl.Request {
489
- cluster , ok := o .(* clusterv1.Cluster )
490
- if ! ok {
491
- return nil
492
- }
493
-
494
- listOpts := []client.ListOption {
495
- client.MatchingLabels {
496
- clusterv1 .ClusterNameLabel : cluster .Name ,
497
- },
498
- }
499
-
500
- if isNamespaced {
501
- listOpts = append (listOpts , client .InNamespace (cluster .Namespace ))
502
- }
503
-
504
- list := & unstructured.UnstructuredList {}
505
- list .SetGroupVersionKind (gvk )
506
- if err := c .List (ctx , list , listOpts ... ); err != nil {
507
- return nil
508
- }
509
-
510
- results := []ctrl.Request {}
511
- for _ , obj := range list .Items {
512
- results = append (results , ctrl.Request {
513
- NamespacedName : client.ObjectKey {Namespace : obj .GetNamespace (), Name : obj .GetName ()},
514
- })
515
- }
516
- return results
517
- }, nil
518
- }
519
-
520
470
// ClusterToTypedObjectsMapper returns a mapper function that gets a cluster and lists all objects for the object passed in
521
471
// and returns a list of requests.
522
472
// Note: This function uses the passed in typed ObjectList and thus with the default client configuration all list calls
0 commit comments