-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
ds.go
52 lines (44 loc) · 1.47 KB
/
ds.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package view
import (
"github.com/derailed/k9s/internal/client"
"github.com/derailed/k9s/internal/dao"
"github.com/derailed/k9s/internal/render"
"github.com/derailed/k9s/internal/ui"
)
// DaemonSet represents a daemon set custom viewer.
type DaemonSet struct {
ResourceViewer
}
// NewDaemonSet returns a new viewer.
func NewDaemonSet(gvr client.GVR) ResourceViewer {
d := DaemonSet{
ResourceViewer: NewPortForwardExtender(
NewRestartExtender(
NewLogsExtender(NewBrowser(gvr), nil),
),
),
}
d.SetBindKeysFn(d.bindKeys)
d.GetTable().SetEnterFn(d.showPods)
d.GetTable().SetColorerFn(render.DaemonSet{}.ColorerFunc())
return &d
}
func (d *DaemonSet) bindKeys(aa ui.KeyActions) {
aa.Add(ui.KeyActions{
ui.KeyShiftD: ui.NewKeyAction("Sort Desired", d.GetTable().SortColCmd("DESIRED", true), false),
ui.KeyShiftC: ui.NewKeyAction("Sort Current", d.GetTable().SortColCmd("CURRENT", true), false),
ui.KeyShiftR: ui.NewKeyAction("Sort Ready", d.GetTable().SortColCmd(readyCol, true), false),
ui.KeyShiftU: ui.NewKeyAction("Sort UpToDate", d.GetTable().SortColCmd(uptodateCol, true), false),
ui.KeyShiftL: ui.NewKeyAction("Sort Available", d.GetTable().SortColCmd(availCol, true), false),
})
}
func (d *DaemonSet) showPods(app *App, model ui.Tabular, _, path string) {
var res dao.DaemonSet
res.Init(app.factory, d.GVR())
ds, err := res.GetInstance(path)
if err != nil {
d.App().Flash().Err(err)
return
}
showPodsFromSelector(app, path, ds.Spec.Selector)
}