add support for stern + fix #507

mine
derailed 2020-01-25 11:00:42 -07:00
parent e89e59d8a8
commit a3b87915f1
7 changed files with 69 additions and 22 deletions

View File

@ -1,6 +1,6 @@
<img src="https://raw.githubusercontent.com/derailed/k9s/master/assets/k9s_small.png" align="right" width="200" height="auto"/>
# Release v0.13.5
# Release v0.13.6
## Notes
@ -12,12 +12,47 @@ On Slack? Please join us [K9slackers](https://join.slack.com/t/k9sers/shared_inv
---
Maintenance Release!
### GH Sponsorships
WOOT!! Big Thank you in this release to [shiv3](https://github.com/shiv3) for your contributions and support for K9s!
Duly noted and so much appreciated!!
---
## Resolved Bugs/Features
* [Issue #507](https://github.com/derailed/k9s/issues/507)
### Bow Or Stern?
Some of you had voiced wanting to enable the multi pod logger [Stern](https://github.com/wercker/stern) from the good folks at [Wercker](https://github.com/wercker). Well now you can!
To make this work the awesome [Tuomo Syvänperä](https://github.com/syvanpera) contributed a PR to enable to plug this in with K9s. Thank you Tuomo!!
By default the filter will be set to the currently selected pod. If you need to change the filter, simply filter the pod view to using your own regex and that's the filter K9s will use. Here is a sample plugin that defines a new K9s shortcut to launch Stern provided of course it is installed on your box...
```yaml
# K9s plugin.yml
plugin:
stern:
shortCut: Ctrl-L
description: "Logs (Stern)"
scopes:
- pods
command: /usr/local/bin/stern # NOTE! Look for the command at this location.
background: false
args:
- --tail
- 50
- $FILTER # NOTE! Pulls the filter out of the pod view.
- -n
- $NAMESPACE
- --context
- $CONTEXT
```
---
## Resolved Bugs/Features/PRs
* [Issue #507](https://github.com/derailed/k9s/issues/511)
* [PR #510](https://github.com/derailed/k9s/pull/510) Thank you!! [Vimal Kumar](https://github.com/vimalk78)
* [PR #340](https://github.com/derailed/k9s/pull/340) ATTA Boy! [Tuomo Syvänperä](https://github.com/syvanpera)
---

View File

@ -234,19 +234,21 @@ func (t *Table) reconcile(ctx context.Context) error {
}
var rows render.Rows
if _, ok := meta.Renderer.(*render.Generic); ok {
table, ok := oo[0].(*metav1beta1.Table)
if !ok {
return fmt.Errorf("expecting a meta table but got %T", oo[0])
}
rows = make(render.Rows, len(table.Rows))
if err := genericHydrate(t.namespace, table, rows, meta.Renderer); err != nil {
return err
}
} else {
rows = make(render.Rows, len(oo))
if err := hydrate(t.namespace, oo, rows, meta.Renderer); err != nil {
return err
if len(oo) > 0 {
if _, ok := meta.Renderer.(*render.Generic); ok {
table, ok := oo[0].(*metav1beta1.Table)
if !ok {
return fmt.Errorf("expecting a meta table but got %T", oo[0])
}
rows = make(render.Rows, len(table.Rows))
if err := genericHydrate(t.namespace, table, rows, meta.Renderer); err != nil {
return err
}
} else {
rows = make(render.Rows, len(oo))
if err := hydrate(t.namespace, oo, rows, meta.Renderer); err != nil {
return err
}
}
}

View File

@ -38,6 +38,7 @@ func ShowDelete(pages *ui.Pages, msg string, ok okFunc, cancel cancelFunc) {
dismissDelete(pages)
cancel()
})
f.SetFocus(2)
confirm := tview.NewModalForm("<Delete>", f)
confirm.SetText(msg)

View File

@ -100,7 +100,7 @@ func sortIndicator(col SortColumn, style config.Table, index int, name string) s
if col.asc {
order = ascIndicator
}
return fmt.Sprintf("%s[%s::]%s[::]", name, style.Header.SorterColor, order)
return fmt.Sprintf("%s[%s::b]%s[::]", name, style.Header.SorterColor, order)
}
func formatCell(field string, padding int) string {

View File

@ -15,7 +15,10 @@ import (
"k8s.io/client-go/tools/portforward"
)
const containerTitle = "Containers"
const (
containerTitle = "Containers"
portsCol = 13
)
// Container represents a container view.
type Container struct {
@ -117,7 +120,7 @@ func (c *Container) isForwardable(path string) ([]string, bool) {
return nil, false
}
portC := c.GetTable().GetSelectedCell(11)
portC := c.GetTable().GetSelectedCell(portsCol)
ports := strings.Split(portC, ",")
if len(ports) == 0 {
c.App().Flash().Err(errors.New("Container exposes no ports"))

View File

@ -82,7 +82,6 @@ func showPodsWithLabels(app *App, path string, sel map[string]string) {
}
func showPods(app *App, path, labelSel, fieldSel string) {
log.Debug().Msgf("SHOW PODS %q -- %q -- %q", path, labelSel, fieldSel)
app.switchNS(client.AllNamespaces)
v := NewPod(client.NewGVR("v1/pods"))

View File

@ -65,7 +65,14 @@ func (t *Table) EnvFn() EnvFunc {
}
func (t *Table) defaultK9sEnv() K9sEnv {
return defaultK9sEnv(t.app, t.GetSelectedItem(), t.GetSelectedRow())
env := defaultK9sEnv(t.app, t.GetSelectedItem(), t.GetSelectedRow())
env["FILTER"] = t.SearchBuff().String()
if env["FILTER"] == "" {
ns, n := client.Namespaced(t.GetSelectedItem())
env["NAMESPACE"], env["FILTER"] = ns, n
}
return env
}
// App returns the current app handle.