Skip to content

Commit

Permalink
Merge pull request #26 from fgiloux/options
Browse files Browse the repository at this point in the history
✨ Add ClusterAwareBuilderWithOptions to the wrapper
  • Loading branch information
openshift-merge-robot authored Oct 4, 2022
2 parents 824b15a + 5044f38 commit a02083d
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions pkg/kcp/wrappers.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,32 @@ func NewClusterAwareMapperProvider(c *rest.Config) (meta.RESTMapper, error) {

return apiutil.NewDynamicRESTMapper(mapperCfg)
}

// ClusterAwareBuilderWithOptions returns a cluster aware Cache constructor that will build
// a cache honoring the options argument, this is useful to specify options like
// SelectorsByObject
// WARNING: If SelectorsByObject is specified, filtered out resources are not
// returned.
// WARNING: If UnsafeDisableDeepCopy is enabled, you must DeepCopy any object
// returned from cache get/list before mutating it.
func ClusterAwareBuilderWithOptions(options cache.Options) cache.NewCacheFunc {
return func(config *rest.Config, opts cache.Options) (cache.Cache, error) {
if options.Scheme == nil {
options.Scheme = opts.Scheme
}
if options.Mapper == nil {
options.Mapper = opts.Mapper
}
if options.Resync == nil {
options.Resync = opts.Resync
}
if options.Namespace == "" {
options.Namespace = opts.Namespace
}
if opts.Resync == nil {
opts.Resync = options.Resync
}

return NewClusterAwareCache(config, options)
}
}

0 comments on commit a02083d

Please sign in to comment.