@@ -58,6 +58,10 @@ type Options struct {
58
58
59
59
// DryRun instructs the client to only perform dry run requests.
60
60
DryRun * bool
61
+
62
+ // KcpClusterDiscoveryCacheSize is the size of the cache for cluster discovery
63
+ // information backing the client's REST mapper.
64
+ KcpClusterDiscoveryCacheSize int
61
65
}
62
66
63
67
// CacheOptions are options for creating a cache-backed client.
@@ -159,6 +163,10 @@ func newClient(config *rest.Config, options Options) (*client, error) {
159
163
}
160
164
}
161
165
166
+ if options .KcpClusterDiscoveryCacheSize == 0 {
167
+ options .KcpClusterDiscoveryCacheSize = 1000
168
+ }
169
+
162
170
// Init a MapperWithContext if none provided
163
171
if options .MapperWithContext == nil {
164
172
options .MapperWithContext = func (context.Context ) (meta.RESTMapper , error ) { return options .Mapper , nil }
@@ -171,7 +179,7 @@ func newClient(config *rest.Config, options Options) (*client, error) {
171
179
mapper : options .MapperWithContext ,
172
180
codecs : serializer .NewCodecFactory (options .Scheme ),
173
181
}
174
- cr , err := lru.New [logicalcluster.Path , clusterResources ](1000 )
182
+ cr , err := lru.New [logicalcluster.Path , clusterResources ](options . KcpClusterDiscoveryCacheSize )
175
183
if err != nil {
176
184
return nil , err
177
185
}
@@ -198,7 +206,7 @@ func newClient(config *rest.Config, options Options) (*client, error) {
198
206
scheme : options .Scheme ,
199
207
mapper : options .Mapper ,
200
208
}
201
- mapperCache , err := lru.New [logicalcluster.Name , meta.RESTMapper ](1000 )
209
+ mapperCache , err := lru.New [logicalcluster.Name , meta.RESTMapper ](options . KcpClusterDiscoveryCacheSize )
202
210
if err != nil {
203
211
return nil , err
204
212
}
0 commit comments