Skip to content

Commit 63d0bbb

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

File tree

10 files changed

+613
-2
lines changed

10 files changed

+613
-2
lines changed

Gopkg.lock

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

Gopkg.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ required = ["sigs.k8s.io/testing_frameworks/integration",
2020
"github.com/go-openapi/spec",
2121
"k8s.io/kube-openapi/pkg/common",
2222
"k8s.io/apiextensions-apiserver",
23+
"github.com/pkg/errors",
2324
]
2425

2526
[[constraint]]

pkg/source/source.go

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

23+
"github.com/pkg/errors"
24+
25+
"k8s.io/apimachinery/pkg/api/meta"
2326
"k8s.io/apimachinery/pkg/runtime"
2427
"k8s.io/client-go/util/workqueue"
2528
"sigs.k8s.io/controller-runtime/pkg/event"
@@ -62,6 +65,7 @@ type Kind struct {
6265

6366
var _ Source = &Kind{}
6467

68+
6569
// Start is internal and should be called only by the Controller to register an EventHandler with the Informer
6670
// to enqueue reconcile.Requests.
6771
func (ks *Kind) Start(handler handler.EventHandler, queue workqueue.RateLimitingInterface,
@@ -80,7 +84,13 @@ 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 {
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+
}
8494
}
8595
i.AddEventHandler(internal.EventHandler{Queue: queue, EventHandler: handler, Predicates: prct})
8696
return nil

vendor/github.com/pkg/errors/.gitignore

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/pkg/errors/.travis.yml

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/pkg/errors/LICENSE

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/pkg/errors/README.md

Lines changed: 52 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/pkg/errors/appveyor.yml

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)