Skip to content

Commit 05e5ab2

Browse files
committed
Prompt to install CRD when Kind no found
1 parent 3db8d34 commit 05e5ab2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/source/source.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121
"sync"
2222

23+
"k8s.io/apimachinery/pkg/api/meta"
2324
"k8s.io/apimachinery/pkg/runtime"
2425
"k8s.io/client-go/util/workqueue"
2526
"sigs.k8s.io/controller-runtime/pkg/event"
@@ -80,7 +81,12 @@ func (ks *Kind) Start(handler handler.EventHandler, queue workqueue.RateLimiting
8081
// Lookup the Informer from the Cache and add an EventHandler which populates the Queue
8182
i, err := ks.cache.GetInformer(ks.Type)
8283
if err != nil {
83-
return err
84+
switch err.(type) {
85+
case *meta.NoKindMatchError:
86+
return fmt.Errorf("must install CRD %s before calling Start", err.(*meta.NoKindMatchError).GroupKind)
87+
default:
88+
return err
89+
}
8490
}
8591
i.AddEventHandler(internal.EventHandler{Queue: queue, EventHandler: handler, Predicates: prct})
8692
return nil

0 commit comments

Comments
 (0)