@@ -51,16 +51,7 @@ var _ error = (*ErrCacheNotStarted)(nil)
5151// ErrResourceNotCached indicates that the resource type
5252// the client asked the cache for is not cached, i.e. the
5353// corresponding informer does not exist yet.
54- type ErrResourceNotCached struct {
55- GVK schema.GroupVersionKind
56- }
57-
58- // Error returns the error
59- func (r ErrResourceNotCached ) Error () string {
60- return fmt .Sprintf ("%s is not cached" , r .GVK .String ())
61- }
62-
63- var _ error = (* ErrResourceNotCached )(nil )
54+ type ErrResourceNotCached = internal.ErrResourceNotCached
6455
6556// informerCache is a Kubernetes Object cache populated from internal.Informers.
6657// informerCache wraps internal.Informers.
@@ -157,7 +148,7 @@ func (ic *informerCache) GetInformerForKind(ctx context.Context, gvk schema.Grou
157148 return nil , err
158149 }
159150
160- _ , i , err := ic .Informers .Get (ctx , gvk , obj , applyGetOptions (opts ... ))
151+ _ , i , err := ic .Informers .Get (ctx , gvk , obj , false , applyGetOptions (opts ... ))
161152 if err != nil {
162153 return nil , err
163154 }
@@ -171,23 +162,19 @@ func (ic *informerCache) GetInformer(ctx context.Context, obj client.Object, opt
171162 return nil , err
172163 }
173164
174- _ , i , err := ic .Informers .Get (ctx , gvk , obj , applyGetOptions (opts ... ))
165+ _ , i , err := ic .Informers .Get (ctx , gvk , obj , false , applyGetOptions (opts ... ))
175166 if err != nil {
176167 return nil , err
177168 }
178169 return i .Informer , nil
179170}
180171
181172func (ic * informerCache ) getInformerForKind (ctx context.Context , gvk schema.GroupVersionKind , obj runtime.Object ) (bool , * internal.Cache , error ) {
182- if ic .readerFailOnMissingInformer {
183- cache , started , ok := ic .Informers .Peek (gvk , obj )
184- if ! ok {
185- return false , nil , & ErrResourceNotCached {GVK : gvk }
186- }
187- return started , cache , nil
173+ started , cache , err := ic .Informers .Get (ctx , gvk , obj , ic .readerFailOnMissingInformer , & internal.GetOptions {})
174+ if err != nil {
175+ return false , nil , err
188176 }
189-
190- return ic .Informers .Get (ctx , gvk , obj , & internal.GetOptions {})
177+ return started , cache , nil
191178}
192179
193180// RemoveInformer deactivates and removes the informer from the cache.
0 commit comments