MCPcopy
hub / github.com/derailed/k9s / ForResource

Method ForResource

internal/watch/factory.go:251–270  ·  view source on GitHub ↗

ForResource returns an informer for a given resource.

(ns string, gvr *client.GVR)

Source from the content-addressed store, hash-verified

249
250// ForResource returns an informer for a given resource.
251func (f *Factory) ForResource(ns string, gvr *client.GVR) (informers.GenericInformer, error) {
252 fact, err := f.ensureFactory(ns)
253 if err != nil {
254 return nil, err
255 }
256 inf := fact.ForResource(gvr.GVR())
257 if inf == nil {
258 slog.Error("No informer found",
259 slogs.GVR, gvr,
260 slogs.Namespace, ns,
261 )
262 return inf, nil
263 }
264
265 f.mx.RLock()
266 defer f.mx.RUnlock()
267 fact.Start(f.stopChan)
268
269 return inf, nil
270}
271
272func (f *Factory) ensureFactory(ns string) (di.DynamicSharedInformerFactory, error) {
273 if client.IsClusterWide(ns) {

Callers 2

CanForResourceMethod · 0.95
CanForInstanceMethod · 0.95

Implementers 7

tableFactoryinternal/model/table_test.go
testFactoryinternal/model/log_test.go
testFactoryinternal/view/pf_extender_test.go
testFactoryinternal/xray/container_test.go
testFactoryinternal/dao/utils_test.go
podFactoryinternal/dao/container_test.go
Factoryinternal/watch/factory.go

Calls 5

ensureFactoryMethod · 0.95
ForResourceMethod · 0.65
GVRMethod · 0.65
StartMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected