@@ -223,6 +223,18 @@ type Options struct {
223
223
// DefaultNamespaces.
224
224
DefaultUnsafeDisableDeepCopy * bool
225
225
226
+ // DefaultEnableWatchBookmarks requests watch events with type "BOOKMARK".
227
+ // Servers that do not implement bookmarks may ignore this flag and
228
+ // bookmarks are sent at the server's discretion. Clients should not
229
+ // assume bookmarks are returned at any specific interval, nor may they
230
+ // assume the server will send any BOOKMARK event during a session.
231
+ //
232
+ // This will be used for all object types, unless it is set in ByObject or
233
+ // DefaultNamespaces.
234
+ //
235
+ // Defaults to true.
236
+ DefaultEnableWatchBookmarks * bool
237
+
226
238
// ByObject restricts the cache's ListWatch to the desired fields per GVK at the specified object.
227
239
// If unset, this will fall through to the Default* settings.
228
240
ByObject map [client.Object ]ByObject
@@ -273,6 +285,15 @@ type ByObject struct {
273
285
// Be very careful with this, when enabled you must DeepCopy any object before mutating it,
274
286
// otherwise you will mutate the object in the cache.
275
287
UnsafeDisableDeepCopy * bool
288
+
289
+ // EnableWatchBookmarks requests watch events with type "BOOKMARK".
290
+ // Servers that do not implement bookmarks may ignore this flag and
291
+ // bookmarks are sent at the server's discretion. Clients should not
292
+ // assume bookmarks are returned at any specific interval, nor may they
293
+ // assume the server will send any BOOKMARK event during a session.
294
+ //
295
+ // Defaults to true.
296
+ EnableWatchBookmarks * bool
276
297
}
277
298
278
299
// Config describes all potential options for a given watch.
@@ -299,6 +320,15 @@ type Config struct {
299
320
// UnsafeDisableDeepCopy specifies if List and Get requests against the
300
321
// cache should not DeepCopy. A nil value allows to default this.
301
322
UnsafeDisableDeepCopy * bool
323
+
324
+ // EnableWatchBookmarks requests watch events with type "BOOKMARK".
325
+ // Servers that do not implement bookmarks may ignore this flag and
326
+ // bookmarks are sent at the server's discretion. Clients should not
327
+ // assume bookmarks are returned at any specific interval, nor may they
328
+ // assume the server will send any BOOKMARK event during a session.
329
+ //
330
+ // Defaults to true.
331
+ EnableWatchBookmarks * bool
302
332
}
303
333
304
334
// NewCacheFunc - Function for creating a new cache from the options and a rest config.
@@ -368,6 +398,7 @@ func optionDefaultsToConfig(opts *Options) Config {
368
398
FieldSelector : opts .DefaultFieldSelector ,
369
399
Transform : opts .DefaultTransform ,
370
400
UnsafeDisableDeepCopy : opts .DefaultUnsafeDisableDeepCopy ,
401
+ EnableWatchBookmarks : opts .DefaultEnableWatchBookmarks ,
371
402
}
372
403
}
373
404
@@ -377,6 +408,7 @@ func byObjectToConfig(byObject ByObject) Config {
377
408
FieldSelector : byObject .Field ,
378
409
Transform : byObject .Transform ,
379
410
UnsafeDisableDeepCopy : byObject .UnsafeDisableDeepCopy ,
411
+ EnableWatchBookmarks : byObject .EnableWatchBookmarks ,
380
412
}
381
413
}
382
414
@@ -399,6 +431,7 @@ func newCache(restConfig *rest.Config, opts Options) newCacheFunc {
399
431
Transform : config .Transform ,
400
432
WatchErrorHandler : opts .DefaultWatchErrorHandler ,
401
433
UnsafeDisableDeepCopy : ptr .Deref (config .UnsafeDisableDeepCopy , false ),
434
+ EnableWatchBookmarks : ptr .Deref (config .EnableWatchBookmarks , true ),
402
435
NewInformer : opts .newInformer ,
403
436
}),
404
437
readerFailOnMissingInformer : opts .ReaderFailOnMissingInformer ,
@@ -483,6 +516,7 @@ func defaultOpts(config *rest.Config, opts Options) (Options, error) {
483
516
byObject .Field = defaultedConfig .FieldSelector
484
517
byObject .Transform = defaultedConfig .Transform
485
518
byObject .UnsafeDisableDeepCopy = defaultedConfig .UnsafeDisableDeepCopy
519
+ byObject .EnableWatchBookmarks = defaultedConfig .EnableWatchBookmarks
486
520
}
487
521
488
522
opts .ByObject [obj ] = byObject
@@ -524,7 +558,9 @@ func defaultConfig(toDefault, defaultFrom Config) Config {
524
558
if toDefault .UnsafeDisableDeepCopy == nil {
525
559
toDefault .UnsafeDisableDeepCopy = defaultFrom .UnsafeDisableDeepCopy
526
560
}
527
-
561
+ if toDefault .EnableWatchBookmarks == nil {
562
+ toDefault .EnableWatchBookmarks = defaultFrom .EnableWatchBookmarks
563
+ }
528
564
return toDefault
529
565
}
530
566
0 commit comments