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