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