@@ -112,6 +112,7 @@ type Options struct {
112
112
// NewClient is the func that creates the client to be used by the manager.
113
113
// If not set this will create the default DelegatingClient that will
114
114
// use the cache for reads and the client for writes.
115
+ // NOTE: The default client will not cache Unstructured.
115
116
NewClient NewClientFunc
116
117
117
118
// ClientDisableCacheFor tells the client that, if any cache is used, to bypass it
@@ -255,16 +256,28 @@ func setOptionsDefaults(options Options) Options {
255
256
// NewClientFunc allows a user to define how to create a client.
256
257
type NewClientFunc func (cache cache.Cache , config * rest.Config , options client.Options , uncachedObjects ... client.Object ) (client.Client , error )
257
258
258
- // DefaultNewClient creates the default caching client.
259
+ // DefaultNewClient creates the default caching client, that will not cache Unstructured .
259
260
func DefaultNewClient (cache cache.Cache , config * rest.Config , options client.Options , uncachedObjects ... client.Object ) (client.Client , error ) {
261
+ return newClient (cache , config , options , false , uncachedObjects )
262
+ }
263
+
264
+ // CacheUnstructuredNewClient creates a caching client that will cache Unstructured.
265
+ func CacheUnstructuredNewClient (cache cache.Cache , config * rest.Config , options client.Options , uncachedObjects ... client.Object ) (client.Client , error ) {
266
+ return newClient (cache , config , options , true , uncachedObjects )
267
+ }
268
+
269
+ var _ NewClientFunc = CacheUnstructuredNewClient
270
+
271
+ func newClient (cache cache.Cache , config * rest.Config , options client.Options , cacheUnstructured bool , uncachedObjects []client.Object ) (client.Client , error ) {
260
272
c , err := client .New (config , options )
261
273
if err != nil {
262
274
return nil , err
263
275
}
264
276
265
277
return client .NewDelegatingClient (client.NewDelegatingClientInput {
266
- CacheReader : cache ,
267
- Client : c ,
268
- UncachedObjects : uncachedObjects ,
278
+ CacheReader : cache ,
279
+ Client : c ,
280
+ UncachedObjects : uncachedObjects ,
281
+ CacheUnstructured : cacheUnstructured ,
269
282
})
270
283
}
0 commit comments