@@ -49,6 +49,7 @@ type InformersOpts struct {
49
49
Selector Selector
50
50
Transform cache.TransformFunc
51
51
UnsafeDisableDeepCopy bool
52
+ WatchErrorHandler cache.WatchErrorHandler
52
53
}
53
54
54
55
// NewInformers creates a new InformersMap that can create informers under the hood.
@@ -76,6 +77,7 @@ func NewInformers(config *rest.Config, options *InformersOpts) *Informers {
76
77
transform : options .Transform ,
77
78
unsafeDisableDeepCopy : options .UnsafeDisableDeepCopy ,
78
79
newInformer : newInformer ,
80
+ watchErrorHandler : options .WatchErrorHandler ,
79
81
}
80
82
}
81
83
@@ -159,6 +161,11 @@ type Informers struct {
159
161
160
162
// NewInformer allows overriding of the shared index informer constructor for testing.
161
163
newInformer func (cache.ListerWatcher , runtime.Object , time.Duration , cache.Indexers ) cache.SharedIndexInformer
164
+
165
+ // WatchErrorHandler allows the shared index informer's
166
+ // watchErrorHandler to be set by overriding the options
167
+ // or to use the default watchErrorHandler
168
+ watchErrorHandler cache.WatchErrorHandler
162
169
}
163
170
164
171
// Start calls Run on each of the informers and sets started to true. Blocks on the context.
@@ -323,6 +330,13 @@ func (ip *Informers) addInformerToMap(gvk schema.GroupVersionKind, obj runtime.O
323
330
cache .NamespaceIndex : cache .MetaNamespaceIndexFunc ,
324
331
})
325
332
333
+ // Set WatchErrorHandler on SharedIndexInformer if set
334
+ if ip .watchErrorHandler != nil {
335
+ if err := sharedIndexInformer .SetWatchErrorHandler (ip .watchErrorHandler ); err != nil {
336
+ return nil , false , err
337
+ }
338
+ }
339
+
326
340
// Check to see if there is a transformer for this gvk
327
341
if err := sharedIndexInformer .SetTransform (ip .transform ); err != nil {
328
342
return nil , false , err
0 commit comments