Skip to content

Commit 869a3a0

Browse files
stttsturkenh
authored andcommitted
Address comments
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
1 parent 3a5783c commit 869a3a0

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pkg/client/client.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ type Options struct {
5858

5959
// DryRun instructs the client to only perform dry run requests.
6060
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
6165
}
6266

6367
// CacheOptions are options for creating a cache-backed client.
@@ -159,6 +163,10 @@ func newClient(config *rest.Config, options Options) (*client, error) {
159163
}
160164
}
161165

166+
if options.KcpClusterDiscoveryCacheSize == 0 {
167+
options.KcpClusterDiscoveryCacheSize = 1000
168+
}
169+
162170
// Init a MapperWithContext if none provided
163171
if options.MapperWithContext == nil {
164172
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) {
171179
mapper: options.MapperWithContext,
172180
codecs: serializer.NewCodecFactory(options.Scheme),
173181
}
174-
cr, err := lru.New[logicalcluster.Path, clusterResources](1000)
182+
cr, err := lru.New[logicalcluster.Path, clusterResources](options.KcpClusterDiscoveryCacheSize)
175183
if err != nil {
176184
return nil, err
177185
}
@@ -198,7 +206,7 @@ func newClient(config *rest.Config, options Options) (*client, error) {
198206
scheme: options.Scheme,
199207
mapper: options.Mapper,
200208
}
201-
mapperCache, err := lru.New[logicalcluster.Name, meta.RESTMapper](1000)
209+
mapperCache, err := lru.New[logicalcluster.Name, meta.RESTMapper](options.KcpClusterDiscoveryCacheSize)
202210
if err != nil {
203211
return nil, err
204212
}

0 commit comments

Comments
 (0)