added context info when running commands
parent
591839a42f
commit
3dcf1b0573
|
|
@ -37,15 +37,6 @@ func runK(app *appView, args ...string) bool {
|
|||
})
|
||||
}
|
||||
|
||||
func run1(app *appView, bin string, args ...string) bool {
|
||||
return app.Suspend(func() {
|
||||
if err := execute(bin, args...); err != nil {
|
||||
log.Error().Msgf("Command exited: %T %v %v", err, err, args)
|
||||
app.flash(flashErr, "Command exited: ", err.Error())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func execute(bin string, args ...string) error {
|
||||
clearScreen()
|
||||
log.Debug().Msgf("Running command > %s %s", bin, strings.Join(args, " "))
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package views
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/derailed/k9s/internal/config"
|
||||
"github.com/derailed/k9s/internal/resource"
|
||||
"github.com/gdamore/tcell"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
|
@ -140,7 +141,11 @@ func (v *podView) showPicker(cc []string) {
|
|||
|
||||
func (v *podView) shellIn(path, co string) {
|
||||
ns, po := namespaced(path)
|
||||
args := []string{"exec", "-it", "-n", ns, po}
|
||||
args := make([]string, 0, 12)
|
||||
args = append(args, "exec", "-it")
|
||||
args = append(args, "--context", config.Root.K9s.CurrentContext)
|
||||
args = append(args, "-n", ns)
|
||||
args = append(args, po)
|
||||
if len(co) != 0 {
|
||||
args = append(args, "-c", co)
|
||||
}
|
||||
|
|
@ -153,13 +158,16 @@ func (v *podView) showLogs(path, co string, previous bool) {
|
|||
ns, po := namespaced(path)
|
||||
args := make([]string, 0, 10)
|
||||
args = append(args, "logs", "-f")
|
||||
args = append(args, "-n", ns)
|
||||
args = append(args, "--context", config.Root.K9s.CurrentContext)
|
||||
if len(co) != 0 {
|
||||
args = append(args, "-c", co)
|
||||
v.app.flash(flashInfo, fmt.Sprintf("Viewing logs from container %s on pod %s", co, po))
|
||||
} else {
|
||||
v.app.flash(flashInfo, fmt.Sprintf("Viewing logs from pod %s", po))
|
||||
}
|
||||
runK(v.app, append(args, "-n", ns, po)...)
|
||||
args = append(args, po)
|
||||
runK(v.app, args...)
|
||||
}
|
||||
|
||||
func (v *podView) extraActions(aa keyActions) {
|
||||
|
|
|
|||
|
|
@ -193,8 +193,14 @@ func (v *resourceView) editCmd(evt *tcell.EventKey) *tcell.EventKey {
|
|||
if !v.rowSelected() {
|
||||
return evt
|
||||
}
|
||||
ns, s := namespaced(v.selectedItem)
|
||||
runK(v.app, "edit", v.list.GetName(), "-n", ns, s)
|
||||
ns, po := namespaced(v.selectedItem)
|
||||
args := make([]string, 0, 10)
|
||||
args = append(args, "edit")
|
||||
args = append(args, v.list.GetName())
|
||||
args = append(args, "-n", ns)
|
||||
args = append(args, "--context", config.Root.K9s.CurrentContext)
|
||||
args = append(args, po)
|
||||
runK(v.app, args...)
|
||||
return evt
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue