File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ import (
20
20
"fmt"
21
21
"sync"
22
22
23
+ "github.com/pkg/errors"
24
+
25
+ "k8s.io/apimachinery/pkg/api/meta"
23
26
"k8s.io/apimachinery/pkg/runtime"
24
27
"k8s.io/client-go/util/workqueue"
25
28
"sigs.k8s.io/controller-runtime/pkg/event"
@@ -62,6 +65,7 @@ type Kind struct {
62
65
63
66
var _ Source = & Kind {}
64
67
68
+
65
69
// Start is internal and should be called only by the Controller to register an EventHandler with the Informer
66
70
// to enqueue reconcile.Requests.
67
71
func (ks * Kind ) Start (handler handler.EventHandler , queue workqueue.RateLimitingInterface ,
@@ -80,7 +84,13 @@ func (ks *Kind) Start(handler handler.EventHandler, queue workqueue.RateLimiting
80
84
// Lookup the Informer from the Cache and add an EventHandler which populates the Queue
81
85
i , err := ks .cache .GetInformer (ks .Type )
82
86
if err != nil {
83
- return err
87
+ switch err .(type ) {
88
+ case * meta.NoKindMatchError :
89
+ return errors .Wrapf (err , "if %s is a CRD, should install it before calling Start" ,
90
+ err .(* meta.NoKindMatchError ).GroupKind )
91
+ default :
92
+ return err
93
+ }
84
94
}
85
95
i .AddEventHandler (internal.EventHandler {Queue : queue , EventHandler : handler , Predicates : prct })
86
96
return nil
You can’t perform that action at this time.
0 commit comments