Skip to content

Commit f723dda

Browse files
authored
Merge pull request kubernetes-sigs#129 from interma/prompt_nocrd
Prompt to install CRD when Kind no found
2 parents f7e0e5a + 534de15 commit f723dda

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,18 +20,22 @@ 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
toolscache "k8s.io/client-go/tools/cache"
3133
"sigs.k8s.io/controller-runtime/pkg/cache"
3234
"sigs.k8s.io/controller-runtime/pkg/predicate"
3335
)
3436

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

0 commit comments

Comments
 (0)