@@ -223,6 +223,16 @@ 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
+ DefaultEnableWatchBookmarks * bool
235
+
226
236
// ByObject restricts the cache's ListWatch to the desired fields per GVK at the specified object.
227
237
// If unset, this will fall through to the Default* settings.
228
238
ByObject map [client.Object ]ByObject
@@ -273,6 +283,13 @@ type ByObject struct {
273
283
// Be very careful with this, when enabled you must DeepCopy any object before mutating it,
274
284
// otherwise you will mutate the object in the cache.
275
285
UnsafeDisableDeepCopy * bool
286
+
287
+ // EnableWatchBookmarks requests watch events with type "BOOKMARK".
288
+ // Servers that do not implement bookmarks may ignore this flag and
289
+ // bookmarks are sent at the server's discretion. Clients should not
290
+ // assume bookmarks are returned at any specific interval, nor may they
291
+ // assume the server will send any BOOKMARK event during a session.
292
+ EnableWatchBookmarks * bool
276
293
}
277
294
278
295
// Config describes all potential options for a given watch.
@@ -299,6 +316,13 @@ type Config struct {
299
316
// UnsafeDisableDeepCopy specifies if List and Get requests against the
300
317
// cache should not DeepCopy. A nil value allows to default this.
301
318
UnsafeDisableDeepCopy * bool
319
+
320
+ // EnableWatchBookmarks requests watch events with type "BOOKMARK".
321
+ // Servers that do not implement bookmarks may ignore this flag and
322
+ // bookmarks are sent at the server's discretion. Clients should not
323
+ // assume bookmarks are returned at any specific interval, nor may they
324
+ // assume the server will send any BOOKMARK event during a session.
325
+ EnableWatchBookmarks * bool
302
326
}
303
327
304
328
// NewCacheFunc - Function for creating a new cache from the options and a rest config.
@@ -368,6 +392,7 @@ func optionDefaultsToConfig(opts *Options) Config {
368
392
FieldSelector : opts .DefaultFieldSelector ,
369
393
Transform : opts .DefaultTransform ,
370
394
UnsafeDisableDeepCopy : opts .DefaultUnsafeDisableDeepCopy ,
395
+ EnableWatchBookmarks : opts .DefaultEnableWatchBookmarks ,
371
396
}
372
397
}
373
398
@@ -377,6 +402,7 @@ func byObjectToConfig(byObject ByObject) Config {
377
402
FieldSelector : byObject .Field ,
378
403
Transform : byObject .Transform ,
379
404
UnsafeDisableDeepCopy : byObject .UnsafeDisableDeepCopy ,
405
+ EnableWatchBookmarks : byObject .EnableWatchBookmarks ,
380
406
}
381
407
}
382
408
@@ -399,6 +425,7 @@ func newCache(restConfig *rest.Config, opts Options) newCacheFunc {
399
425
Transform : config .Transform ,
400
426
WatchErrorHandler : opts .DefaultWatchErrorHandler ,
401
427
UnsafeDisableDeepCopy : ptr .Deref (config .UnsafeDisableDeepCopy , false ),
428
+ EnableWatchBookmarks : ptr .Deref (config .EnableWatchBookmarks , true ),
402
429
NewInformer : opts .newInformer ,
403
430
}),
404
431
readerFailOnMissingInformer : opts .ReaderFailOnMissingInformer ,
@@ -508,6 +535,11 @@ func defaultOpts(config *rest.Config, opts Options) (Options, error) {
508
535
if opts .SyncPeriod == nil {
509
536
opts .SyncPeriod = & defaultSyncPeriod
510
537
}
538
+
539
+ // Default enable watch bookmarks, unless set.
540
+ if opts .DefaultEnableWatchBookmarks == nil {
541
+ opts .DefaultEnableWatchBookmarks = ptr .To (true )
542
+ }
511
543
return opts , nil
512
544
}
513
545
0 commit comments