Disallow shell access when in readonly mode
parent
0ad25ba2f5
commit
094853c10d
|
|
@ -40,11 +40,21 @@ func NewContainer(gvr client.GVR) ResourceViewer {
|
|||
// Name returns the component name.
|
||||
func (c *Container) Name() string { return containerTitle }
|
||||
|
||||
func (c *Container) bindDangerousKeys(aa ui.KeyActions) {
|
||||
aa.Add(ui.KeyActions{
|
||||
ui.KeyS: ui.NewKeyAction("Shell", c.shellCmd, true),
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Container) bindKeys(aa ui.KeyActions) {
|
||||
aa.Delete(tcell.KeyCtrlSpace, ui.KeySpace)
|
||||
|
||||
if !c.App().Config.K9s.GetReadOnly() {
|
||||
c.bindDangerousKeys(aa)
|
||||
}
|
||||
|
||||
aa.Add(ui.KeyActions{
|
||||
ui.KeyShiftF: ui.NewKeyAction("PortForward", c.portFwdCmd, true),
|
||||
ui.KeyS: ui.NewKeyAction("Shell", c.shellCmd, true),
|
||||
ui.KeyShiftC: ui.NewKeyAction("Sort CPU", c.GetTable().SortColCmd(6, false), false),
|
||||
ui.KeyShiftM: ui.NewKeyAction("Sort MEM", c.GetTable().SortColCmd(7, false), false),
|
||||
ui.KeyShiftX: ui.NewKeyAction("Sort %CPU (REQ)", c.GetTable().SortColCmd(8, false), false),
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ func NewPod(gvr client.GVR) ResourceViewer {
|
|||
func (p *Pod) bindDangerousKeys(aa ui.KeyActions) {
|
||||
aa.Add(ui.KeyActions{
|
||||
tcell.KeyCtrlK: ui.NewKeyAction("Kill", p.killCmd, true),
|
||||
ui.KeyS: ui.NewKeyAction("Shell", p.shellCmd, true),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -47,7 +48,6 @@ func (p *Pod) bindKeys(aa ui.KeyActions) {
|
|||
}
|
||||
|
||||
aa.Add(ui.KeyActions{
|
||||
ui.KeyS: ui.NewKeyAction("Shell", p.shellCmd, true),
|
||||
ui.KeyShiftR: ui.NewKeyAction("Sort Ready", p.GetTable().SortColCmd(1, true), false),
|
||||
ui.KeyShiftS: ui.NewKeyAction("Sort Status", p.GetTable().SortColCmd(2, true), false),
|
||||
ui.KeyShiftT: ui.NewKeyAction("Sort Restart", p.GetTable().SortColCmd(3, false), false),
|
||||
|
|
|
|||
Loading…
Reference in New Issue