Skip to content

Commit 83ac60c

Browse files
committed
Address comments
Signed-off-by: Dr. Stefan Schimanski <[email protected]>
1 parent ef8fdeb commit 83ac60c

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
@@ -62,6 +62,10 @@ type Options struct {
6262

6363
// DryRun instructs the client to only perform dry run requests.
6464
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
6569
}
6670

6771
// WarningHandlerOptions are options for configuring a
@@ -176,6 +180,10 @@ func newClient(config *rest.Config, options Options) (*client, error) {
176180
}
177181
}
178182

183+
if options.KcpClusterDiscoveryCacheSize == 0 {
184+
options.KcpClusterDiscoveryCacheSize = 1000
185+
}
186+
179187
// Init a MapperWithContext if none provided
180188
if options.MapperWithContext == nil {
181189
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) {
188196
mapper: options.MapperWithContext,
189197
codecs: serializer.NewCodecFactory(options.Scheme),
190198
}
191-
cr, err := lru.New[logicalcluster.Path, clusterResources](1000)
199+
cr, err := lru.New[logicalcluster.Path, clusterResources](options.KcpClusterDiscoveryCacheSize)
192200
if err != nil {
193201
return nil, err
194202
}
@@ -215,7 +223,7 @@ func newClient(config *rest.Config, options Options) (*client, error) {
215223
scheme: options.Scheme,
216224
mapper: options.Mapper,
217225
}
218-
mapperCache, err := lru.New[logicalcluster.Name, meta.RESTMapper](1000)
226+
mapperCache, err := lru.New[logicalcluster.Name, meta.RESTMapper](options.KcpClusterDiscoveryCacheSize)
219227
if err != nil {
220228
return nil, err
221229
}

0 commit comments

Comments
 (0)