mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-04 08:35:10 +00:00
cache: add error handling to informers
When creating an informer, this adds a way to add custom error handling, so that Kubernetes tooling can properly surface the errors to the end user. Fixes https://github.com/kubernetes/client-go/issues/155 Kubernetes-commit: 435b40aa1e5c0ae44e0aeb9aa6dbde79838b3390
This commit is contained in:
committed by
Kubernetes Publisher
parent
8e91b7aa91
commit
ccd5becdff
@@ -62,6 +62,9 @@ type FakeControllerSource struct {
|
||||
changes []watch.Event // one change per resourceVersion
|
||||
Broadcaster *watch.Broadcaster
|
||||
lastRV int
|
||||
|
||||
// Set this to simulate an error on List()
|
||||
ListError error
|
||||
}
|
||||
|
||||
type FakePVControllerSource struct {
|
||||
@@ -174,6 +177,11 @@ func (f *FakeControllerSource) getListItemsLocked() ([]runtime.Object, error) {
|
||||
func (f *FakeControllerSource) List(options metav1.ListOptions) (runtime.Object, error) {
|
||||
f.lock.RLock()
|
||||
defer f.lock.RUnlock()
|
||||
|
||||
if f.ListError != nil {
|
||||
return nil, f.ListError
|
||||
}
|
||||
|
||||
list, err := f.getListItemsLocked()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Reference in New Issue
Block a user