oops missed a few files. My bad!
parent
aab46f6aad
commit
565cd12fd3
|
|
@ -43,7 +43,7 @@ func AccessorFor(f Factory, gvr client.GVR) (Accessor, error) {
|
||||||
r, ok := m[gvr]
|
r, ok := m[gvr]
|
||||||
if !ok {
|
if !ok {
|
||||||
r = &Generic{}
|
r = &Generic{}
|
||||||
log.Warn().Msgf("No DAO registry entry for %q. Using factory!", gvr)
|
log.Debug().Msgf("No DAO registry entry for %q. Using factory!", gvr)
|
||||||
}
|
}
|
||||||
r.Init(f, gvr)
|
r.Init(f, gvr)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ func showPods(app *App, path, labelSel, fieldSel string) {
|
||||||
app.switchNS("")
|
app.switchNS("")
|
||||||
|
|
||||||
v := NewPod(client.NewGVR("v1/pods"))
|
v := NewPod(client.NewGVR("v1/pods"))
|
||||||
v.SetContextFn(podCtx(path, labelSel, fieldSel))
|
v.SetContextFn(podCtx(app, path, labelSel, fieldSel))
|
||||||
v.GetTable().SetColorerFn(render.Pod{}.ColorerFunc())
|
v.GetTable().SetColorerFn(render.Pod{}.ColorerFunc())
|
||||||
|
|
||||||
ns, _ := client.Namespaced(path)
|
ns, _ := client.Namespaced(path)
|
||||||
|
|
@ -113,10 +113,20 @@ func showPods(app *App, path, labelSel, fieldSel string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func podCtx(path, labelSel, fieldSel string) ContextFunc {
|
func podCtx(app *App, path, labelSel, fieldSel string) ContextFunc {
|
||||||
return func(ctx context.Context) context.Context {
|
return func(ctx context.Context) context.Context {
|
||||||
ctx = context.WithValue(ctx, internal.KeyPath, path)
|
ctx = context.WithValue(ctx, internal.KeyPath, path)
|
||||||
ctx = context.WithValue(ctx, internal.KeyLabels, labelSel)
|
ctx = context.WithValue(ctx, internal.KeyLabels, labelSel)
|
||||||
|
|
||||||
|
ns, _ := client.Namespaced(path)
|
||||||
|
log.Debug().Msgf("POD METRICS in NS %q", ns)
|
||||||
|
mx := client.NewMetricsServer(app.factory.Client())
|
||||||
|
nmx, err := mx.FetchPodsMetrics(ns)
|
||||||
|
if err != nil {
|
||||||
|
log.Warn().Err(err).Msgf("No pods metrics")
|
||||||
|
}
|
||||||
|
ctx = context.WithValue(ctx, internal.KeyMetrics, nmx)
|
||||||
|
|
||||||
return context.WithValue(ctx, internal.KeyFields, fieldSel)
|
return context.WithValue(ctx, internal.KeyFields, fieldSel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ func NewPod(gvr client.GVR) ResourceViewer {
|
||||||
p.SetBindKeysFn(p.bindKeys)
|
p.SetBindKeysFn(p.bindKeys)
|
||||||
p.GetTable().SetEnterFn(p.showContainers)
|
p.GetTable().SetEnterFn(p.showContainers)
|
||||||
p.GetTable().SetColorerFn(render.Pod{}.ColorerFunc())
|
p.GetTable().SetColorerFn(render.Pod{}.ColorerFunc())
|
||||||
p.SetContextFn(p.podMXContext)
|
p.SetContextFn(p.podContext)
|
||||||
|
|
||||||
return &p
|
return &p
|
||||||
}
|
}
|
||||||
|
|
@ -53,31 +53,31 @@ func (p *Pod) bindKeys(aa ui.KeyActions) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pod) podMXContext(ctx context.Context) context.Context {
|
|
||||||
ns, ok := ctx.Value(internal.KeyNamespace).(string)
|
|
||||||
if !ok {
|
|
||||||
log.Error().Err(fmt.Errorf("Expecting context namespace"))
|
|
||||||
}
|
|
||||||
log.Debug().Msgf("POD METRICS in NS %q", ns)
|
|
||||||
mx := client.NewMetricsServer(p.App().factory.Client())
|
|
||||||
nmx, err := mx.FetchPodsMetrics(ns)
|
|
||||||
if err != nil {
|
|
||||||
log.Warn().Err(err).Msgf("No pods metrics")
|
|
||||||
}
|
|
||||||
|
|
||||||
return context.WithValue(ctx, internal.KeyMetrics, nmx)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Pod) showContainers(app *App, ns, gvr, path string) {
|
func (p *Pod) showContainers(app *App, ns, gvr, path string) {
|
||||||
log.Debug().Msgf("SHOW CONTAINERS %q -- %q -- %q", gvr, ns, path)
|
log.Debug().Msgf("SHOW CONTAINERS %q -- %q -- %q", gvr, ns, path)
|
||||||
co := NewContainer(client.NewGVR("containers"))
|
co := NewContainer(client.NewGVR("containers"))
|
||||||
co.SetContextFn(p.podContext)
|
co.SetContextFn(p.coContext)
|
||||||
if err := app.inject(co); err != nil {
|
if err := app.inject(co); err != nil {
|
||||||
app.Flash().Err(err)
|
app.Flash().Err(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pod) podContext(ctx context.Context) context.Context {
|
func (p *Pod) podContext(ctx context.Context) context.Context {
|
||||||
|
ns, ok := ctx.Value(internal.KeyNamespace).(string)
|
||||||
|
if !ok {
|
||||||
|
log.Error().Err(fmt.Errorf("Expecting context namespace"))
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debug().Msgf("POD METRICS in NS %q", ns)
|
||||||
|
mx := client.NewMetricsServer(p.App().factory.Client())
|
||||||
|
nmx, err := mx.FetchPodsMetrics(ns)
|
||||||
|
if err != nil {
|
||||||
|
log.Warn().Err(err).Msgf("No pods metrics")
|
||||||
|
}
|
||||||
|
return context.WithValue(ctx, internal.KeyMetrics, nmx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Pod) coContext(ctx context.Context) context.Context {
|
||||||
return context.WithValue(ctx, internal.KeyPath, p.GetTable().GetSelectedItem())
|
return context.WithValue(ctx, internal.KeyPath, p.GetTable().GetSelectedItem())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,10 +110,11 @@ func (f *Factory) waitForCacheSync(ns string) {
|
||||||
c := make(chan struct{})
|
c := make(chan struct{})
|
||||||
go func(c chan struct{}) {
|
go func(c chan struct{}) {
|
||||||
<-time.After(dur)
|
<-time.After(dur)
|
||||||
log.Warn().Msgf("Wait for sync timed out!")
|
log.Debug().Msgf("Wait for sync timed out!")
|
||||||
close(c)
|
close(c)
|
||||||
}(c)
|
}(c)
|
||||||
fac.WaitForCacheSync(c)
|
fac.WaitForCacheSync(c)
|
||||||
|
log.Debug().Msgf("Sync completed for ns %q", ns)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue