Skip to content

Commit 919948d

Browse files
intermainterma
authored and
interma
committed
Prompt to install CRD when Kind no found
1 parent df7c11e commit 919948d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Gopkg.lock

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/source/source.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,21 @@ 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"
2627
"sigs.k8s.io/controller-runtime/pkg/handler"
2728
"sigs.k8s.io/controller-runtime/pkg/runtime/inject"
29+
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
2830
"sigs.k8s.io/controller-runtime/pkg/source/internal"
2931

3032
"sigs.k8s.io/controller-runtime/pkg/cache"
3133
"sigs.k8s.io/controller-runtime/pkg/predicate"
3234
)
3335

36+
var log = logf.KBLog.WithName("source")
37+
3438
const (
3539
// defaultBufferSize is the default number of event notifications that can be buffered.
3640
defaultBufferSize = 1024
@@ -80,6 +84,10 @@ func (ks *Kind) Start(handler handler.EventHandler, queue workqueue.RateLimiting
8084
// Lookup the Informer from the Cache and add an EventHandler which populates the Queue
8185
i, err := ks.cache.GetInformer(ks.Type)
8286
if err != nil {
87+
if kindMatchErr, ok := err.(*meta.NoKindMatchError); ok {
88+
log.Error(err, "if %s is a CRD, should install it before calling Start",
89+
kindMatchErr.GroupKind)
90+
}
8391
return err
8492
}
8593
i.AddEventHandler(internal.EventHandler{Queue: queue, EventHandler: handler, Predicates: prct})

0 commit comments

Comments
 (0)