@@ -223,6 +223,16 @@ type Options struct {
223223 // DefaultNamespaces.
224224 DefaultUnsafeDisableDeepCopy * bool
225225
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+
226236 // ByObject restricts the cache's ListWatch to the desired fields per GVK at the specified object.
227237 // If unset, this will fall through to the Default* settings.
228238 ByObject map [client.Object ]ByObject
@@ -273,6 +283,13 @@ type ByObject struct {
273283 // Be very careful with this, when enabled you must DeepCopy any object before mutating it,
274284 // otherwise you will mutate the object in the cache.
275285 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
276293}
277294
278295// Config describes all potential options for a given watch.
@@ -299,6 +316,13 @@ type Config struct {
299316 // UnsafeDisableDeepCopy specifies if List and Get requests against the
300317 // cache should not DeepCopy. A nil value allows to default this.
301318 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
302326}
303327
304328// NewCacheFunc - Function for creating a new cache from the options and a rest config.
@@ -368,6 +392,7 @@ func optionDefaultsToConfig(opts *Options) Config {
368392 FieldSelector : opts .DefaultFieldSelector ,
369393 Transform : opts .DefaultTransform ,
370394 UnsafeDisableDeepCopy : opts .DefaultUnsafeDisableDeepCopy ,
395+ EnableWatchBookmarks : opts .DefaultEnableWatchBookmarks ,
371396 }
372397}
373398
@@ -377,6 +402,7 @@ func byObjectToConfig(byObject ByObject) Config {
377402 FieldSelector : byObject .Field ,
378403 Transform : byObject .Transform ,
379404 UnsafeDisableDeepCopy : byObject .UnsafeDisableDeepCopy ,
405+ EnableWatchBookmarks : byObject .EnableWatchBookmarks ,
380406 }
381407}
382408
@@ -399,6 +425,7 @@ func newCache(restConfig *rest.Config, opts Options) newCacheFunc {
399425 Transform : config .Transform ,
400426 WatchErrorHandler : opts .DefaultWatchErrorHandler ,
401427 UnsafeDisableDeepCopy : ptr .Deref (config .UnsafeDisableDeepCopy , false ),
428+ EnableWatchBookmarks : ptr .Deref (config .EnableWatchBookmarks , true ),
402429 NewInformer : opts .newInformer ,
403430 }),
404431 readerFailOnMissingInformer : opts .ReaderFailOnMissingInformer ,
@@ -508,6 +535,11 @@ func defaultOpts(config *rest.Config, opts Options) (Options, error) {
508535 if opts .SyncPeriod == nil {
509536 opts .SyncPeriod = & defaultSyncPeriod
510537 }
538+
539+ // Default enable watch bookmarks, unless set.
540+ if opts .DefaultEnableWatchBookmarks == nil {
541+ opts .DefaultEnableWatchBookmarks = ptr .To (true )
542+ }
511543 return opts , nil
512544}
513545
0 commit comments