@@ -36,6 +36,7 @@ import (
36
36
clientgocache "k8s.io/client-go/tools/cache"
37
37
"k8s.io/client-go/util/workqueue"
38
38
"k8s.io/klog"
39
+ "sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/syncer/util/scheme"
39
40
"sigs.k8s.io/controller-runtime/pkg/cache"
40
41
"sigs.k8s.io/controller-runtime/pkg/client"
41
42
@@ -114,13 +115,17 @@ type ClusterInterface interface {
114
115
115
116
// NewMCController creates a new MultiClusterController.
116
117
func NewMCController (objectType client.Object , objectListType client.ObjectList , rc reconciler.DWReconciler , opts ... OptConfig ) (* MultiClusterController , error ) {
117
- kind := objectType .GetObjectKind ().GroupVersionKind ().Kind
118
+ kinds , _ , err := scheme .Scheme .ObjectKinds (objectType )
119
+ if err != nil || len (kinds ) == 0 {
120
+ return nil , fmt .Errorf ("mccontroller: unknown object kind %+v" , objectType )
121
+ }
122
+
118
123
c := & MultiClusterController {
119
124
objectType : objectType ,
120
- objectKind : kind ,
125
+ objectKind : kinds [ 0 ]. Kind ,
121
126
clusters : make (map [string ]ClusterInterface ),
122
127
Options : Options {
123
- name : fmt .Sprintf ("%s-mccontroller" , strings .ToLower (kind )),
128
+ name : fmt .Sprintf ("%s-mccontroller" , strings .ToLower (kinds [ 0 ]. Kind )),
124
129
JitterPeriod : 1 * time .Second ,
125
130
MaxConcurrentReconciles : constants .DwsControllerWorkerLow ,
126
131
Reconciler : rc ,
0 commit comments