@@ -307,6 +307,10 @@ type ByObject struct {
307307 //
308308 // Defaults to true.
309309 EnableWatchBookmarks * bool
310+
311+ // SyncPeriod determines the minimum frequency at which watched resources are
312+ // reconciled.
313+ SyncPeriod * time.Duration
310314}
311315
312316// Config describes all potential options for a given watch.
@@ -342,6 +346,10 @@ type Config struct {
342346 //
343347 // Defaults to true.
344348 EnableWatchBookmarks * bool
349+
350+ // SyncPeriod determines the minimum frequency at which watched resources are
351+ // reconciled.
352+ SyncPeriod * time.Duration
345353}
346354
347355// NewCacheFunc - Function for creating a new cache from the options and a rest config.
@@ -412,6 +420,7 @@ func optionDefaultsToConfig(opts *Options) Config {
412420 Transform : opts .DefaultTransform ,
413421 UnsafeDisableDeepCopy : opts .DefaultUnsafeDisableDeepCopy ,
414422 EnableWatchBookmarks : opts .DefaultEnableWatchBookmarks ,
423+ SyncPeriod : opts .SyncPeriod ,
415424 }
416425}
417426
@@ -422,6 +431,7 @@ func byObjectToConfig(byObject ByObject) Config {
422431 Transform : byObject .Transform ,
423432 UnsafeDisableDeepCopy : byObject .UnsafeDisableDeepCopy ,
424433 EnableWatchBookmarks : byObject .EnableWatchBookmarks ,
434+ SyncPeriod : byObject .SyncPeriod ,
425435 }
426436}
427437
@@ -435,7 +445,7 @@ func newCache(restConfig *rest.Config, opts Options) newCacheFunc {
435445 HTTPClient : opts .HTTPClient ,
436446 Scheme : opts .Scheme ,
437447 Mapper : opts .Mapper ,
438- ResyncPeriod : * opts . SyncPeriod ,
448+ ResyncPeriod : ptr . Deref ( config . SyncPeriod , defaultSyncPeriod ) ,
439449 Namespace : namespace ,
440450 Selector : internal.Selector {
441451 Label : config .LabelSelector ,
@@ -533,6 +543,7 @@ func defaultOpts(config *rest.Config, opts Options) (Options, error) {
533543 byObject .Transform = defaultedConfig .Transform
534544 byObject .UnsafeDisableDeepCopy = defaultedConfig .UnsafeDisableDeepCopy
535545 byObject .EnableWatchBookmarks = defaultedConfig .EnableWatchBookmarks
546+ byObject .SyncPeriod = defaultedConfig .SyncPeriod
536547 }
537548
538549 opts .ByObject [obj ] = byObject
@@ -554,10 +565,6 @@ func defaultOpts(config *rest.Config, opts Options) (Options, error) {
554565 opts .DefaultNamespaces [namespace ] = cfg
555566 }
556567
557- // Default the resync period to 10 hours if unset
558- if opts .SyncPeriod == nil {
559- opts .SyncPeriod = & defaultSyncPeriod
560- }
561568 return opts , nil
562569}
563570
@@ -577,6 +584,9 @@ func defaultConfig(toDefault, defaultFrom Config) Config {
577584 if toDefault .EnableWatchBookmarks == nil {
578585 toDefault .EnableWatchBookmarks = defaultFrom .EnableWatchBookmarks
579586 }
587+ if toDefault .SyncPeriod == nil {
588+ toDefault .SyncPeriod = defaultFrom .SyncPeriod
589+ }
580590 return toDefault
581591}
582592
0 commit comments