@@ -222,6 +222,18 @@ type Options struct {
222222 // DefaultNamespaces.
223223 DefaultUnsafeDisableDeepCopy * bool
224224
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+
225237 // ByObject restricts the cache's ListWatch to the desired fields per GVK at the specified object.
226238 // If unset, this will fall through to the Default* settings.
227239 ByObject map [client.Object ]ByObject
@@ -272,6 +284,15 @@ type ByObject struct {
272284 // Be very careful with this, when enabled you must DeepCopy any object before mutating it,
273285 // otherwise you will mutate the object in the cache.
274286 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
275296}
276297
277298// Config describes all potential options for a given watch.
@@ -298,6 +319,15 @@ type Config struct {
298319 // UnsafeDisableDeepCopy specifies if List and Get requests against the
299320 // cache should not DeepCopy. A nil value allows to default this.
300321 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
301331}
302332
303333// NewCacheFunc - Function for creating a new cache from the options and a rest config.
@@ -367,6 +397,7 @@ func optionDefaultsToConfig(opts *Options) Config {
367397 FieldSelector : opts .DefaultFieldSelector ,
368398 Transform : opts .DefaultTransform ,
369399 UnsafeDisableDeepCopy : opts .DefaultUnsafeDisableDeepCopy ,
400+ EnableWatchBookmarks : opts .DefaultEnableWatchBookmarks ,
370401 }
371402}
372403
@@ -376,6 +407,7 @@ func byObjectToConfig(byObject ByObject) Config {
376407 FieldSelector : byObject .Field ,
377408 Transform : byObject .Transform ,
378409 UnsafeDisableDeepCopy : byObject .UnsafeDisableDeepCopy ,
410+ EnableWatchBookmarks : byObject .EnableWatchBookmarks ,
379411 }
380412}
381413
@@ -398,6 +430,7 @@ func newCache(restConfig *rest.Config, opts Options) newCacheFunc {
398430 Transform : config .Transform ,
399431 WatchErrorHandler : opts .DefaultWatchErrorHandler ,
400432 UnsafeDisableDeepCopy : ptr .Deref (config .UnsafeDisableDeepCopy , false ),
433+ EnableWatchBookmarks : ptr .Deref (config .EnableWatchBookmarks , false ),
401434 NewInformer : opts .newInformer ,
402435 }),
403436 readerFailOnMissingInformer : opts .ReaderFailOnMissingInformer ,
@@ -482,6 +515,7 @@ func defaultOpts(config *rest.Config, opts Options) (Options, error) {
482515 byObject .Field = defaultedConfig .FieldSelector
483516 byObject .Transform = defaultedConfig .Transform
484517 byObject .UnsafeDisableDeepCopy = defaultedConfig .UnsafeDisableDeepCopy
518+ byObject .EnableWatchBookmarks = defaultedConfig .EnableWatchBookmarks
485519 }
486520
487521 opts .ByObject [obj ] = byObject
@@ -523,7 +557,9 @@ func defaultConfig(toDefault, defaultFrom Config) Config {
523557 if toDefault .UnsafeDisableDeepCopy == nil {
524558 toDefault .UnsafeDisableDeepCopy = defaultFrom .UnsafeDisableDeepCopy
525559 }
526-
560+ if toDefault .EnableWatchBookmarks == nil {
561+ toDefault .EnableWatchBookmarks = defaultFrom .EnableWatchBookmarks
562+ }
527563 return toDefault
528564}
529565
0 commit comments