@@ -150,6 +150,13 @@ func WithRESTConfigModifier(f func(*rest.Config)) Option {
150
150
}
151
151
}
152
152
153
+ // WithCacheOptionsModifier allows to modify the options passed to cache.New the first time it's created.
154
+ func WithCacheOptionsModifier (f func (* cache.Options )) Option {
155
+ return func (c * clusterProxy ) {
156
+ c .cacheOptionsModifier = f
157
+ }
158
+ }
159
+
153
160
// clusterProxy provides a base implementation of the ClusterProxy interface.
154
161
type clusterProxy struct {
155
162
name string
@@ -160,7 +167,8 @@ type clusterProxy struct {
160
167
cache cache.Cache
161
168
onceCache sync.Once
162
169
163
- restConfigModifier func (* rest.Config )
170
+ restConfigModifier func (* rest.Config )
171
+ cacheOptionsModifier func (* cache.Options )
164
172
}
165
173
166
174
// NewClusterProxy returns a clusterProxy given a KubeconfigPath and the scheme defining the types hosted in the cluster.
@@ -255,11 +263,16 @@ func (p *clusterProxy) GetClientSet() *kubernetes.Clientset {
255
263
256
264
func (p * clusterProxy ) GetCache (ctx context.Context ) cache.Cache {
257
265
p .onceCache .Do (func () {
258
- var err error
259
- p .cache , err = cache .New (p .GetRESTConfig (), cache.Options {
266
+ opts := & cache.Options {
260
267
Scheme : p .scheme ,
261
268
Mapper : p .GetClient ().RESTMapper (),
262
- })
269
+ }
270
+ if p .cacheOptionsModifier != nil {
271
+ p .cacheOptionsModifier (opts )
272
+ }
273
+
274
+ var err error
275
+ p .cache , err = cache .New (p .GetRESTConfig (), * opts )
263
276
Expect (err ).ToNot (HaveOccurred (), "Failed to create controller-runtime cache" )
264
277
265
278
go func () {
0 commit comments