Skip to content

Commit c3c1f05

Browse files
authored
Merge pull request #2234 from Fedosin/multiNamespaceCache_defaultOpts
🌱 Don't call defaultOpts for MultiNamespaceCache twice
2 parents a26de2d + 2251039 commit c3c1f05

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pkg/cache/cache.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,16 +194,18 @@ type ByObject struct {
194194

195195
// New initializes and returns a new Cache.
196196
func New(config *rest.Config, opts Options) (Cache, error) {
197-
opts, err := defaultOpts(config, opts)
198-
if err != nil {
199-
return nil, err
200-
}
201197
if len(opts.Namespaces) == 0 {
202198
opts.Namespaces = []string{metav1.NamespaceAll}
203199
}
204200
if len(opts.Namespaces) > 1 {
205201
return newMultiNamespaceCache(config, opts)
206202
}
203+
204+
opts, err := defaultOpts(config, opts)
205+
if err != nil {
206+
return nil, err
207+
}
208+
207209
byGVK, err := convertToInformerOptsByGVK(opts.ByObject, opts.Scheme)
208210
if err != nil {
209211
return nil, err

0 commit comments

Comments
 (0)