@@ -62,6 +62,10 @@ type Options struct {
62
62
63
63
// DryRun instructs the client to only perform dry run requests.
64
64
DryRun * bool
65
+
66
+ // KcpClusterDiscoveryCacheSize is the size of the cache for cluster discovery
67
+ // information backing the client's REST mapper.
68
+ KcpClusterDiscoveryCacheSize int
65
69
}
66
70
67
71
// WarningHandlerOptions are options for configuring a
@@ -176,6 +180,10 @@ func newClient(config *rest.Config, options Options) (*client, error) {
176
180
}
177
181
}
178
182
183
+ if options .KcpClusterDiscoveryCacheSize == 0 {
184
+ options .KcpClusterDiscoveryCacheSize = 1000
185
+ }
186
+
179
187
// Init a MapperWithContext if none provided
180
188
if options .MapperWithContext == nil {
181
189
options .MapperWithContext = func (context.Context ) (meta.RESTMapper , error ) { return options .Mapper , nil }
@@ -188,7 +196,7 @@ func newClient(config *rest.Config, options Options) (*client, error) {
188
196
mapper : options .MapperWithContext ,
189
197
codecs : serializer .NewCodecFactory (options .Scheme ),
190
198
}
191
- cr , err := lru.New [logicalcluster.Path , clusterResources ](1000 )
199
+ cr , err := lru.New [logicalcluster.Path , clusterResources ](options . KcpClusterDiscoveryCacheSize )
192
200
if err != nil {
193
201
return nil , err
194
202
}
@@ -215,7 +223,7 @@ func newClient(config *rest.Config, options Options) (*client, error) {
215
223
scheme : options .Scheme ,
216
224
mapper : options .Mapper ,
217
225
}
218
- mapperCache , err := lru.New [logicalcluster.Name , meta.RESTMapper ](1000 )
226
+ mapperCache , err := lru.New [logicalcluster.Name , meta.RESTMapper ](options . KcpClusterDiscoveryCacheSize )
219
227
if err != nil {
220
228
return nil , err
221
229
}
0 commit comments