@@ -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 ,
@@ -508,6 +541,11 @@ func defaultOpts(config *rest.Config, opts Options) (Options, error) {
508
541
if opts .SyncPeriod == nil {
509
542
opts .SyncPeriod = & defaultSyncPeriod
510
543
}
544
+
545
+ // Default enable watch bookmarks, unless set.
546
+ if opts .DefaultEnableWatchBookmarks == nil {
547
+ opts .DefaultEnableWatchBookmarks = ptr .To (true )
548
+ }
511
549
return opts , nil
512
550
}
513
551
@@ -524,7 +562,9 @@ func defaultConfig(toDefault, defaultFrom Config) Config {
524
562
if toDefault .UnsafeDisableDeepCopy == nil {
525
563
toDefault .UnsafeDisableDeepCopy = defaultFrom .UnsafeDisableDeepCopy
526
564
}
527
-
565
+ if toDefault .EnableWatchBookmarks == nil {
566
+ toDefault .EnableWatchBookmarks = defaultFrom .EnableWatchBookmarks
567
+ }
528
568
return toDefault
529
569
}
530
570
0 commit comments