cleaning up deprecation
parent
e2687730bc
commit
ee07b98755
|
|
@ -182,7 +182,7 @@ func (v *Values) refresh(ctx context.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Values) reconcile(ctx context.Context) error {
|
func (v *Values) reconcile(_ context.Context) error {
|
||||||
v.fireResourceChanged(v.lines, v.filter(v.query, v.lines))
|
v.fireResourceChanged(v.lines, v.filter(v.query, v.lines))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -98,13 +98,3 @@ func (e *Event) Render(o interface{}, ns string, r *Row) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Event) cellFor(n string, row metav1beta1.TableRow) (string, bool) {
|
|
||||||
for i, h := range e.table.ColumnDefinitions {
|
|
||||||
if h.Name == n {
|
|
||||||
return fmt.Sprintf("%v", row.Cells[i]), true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return "", false
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package render
|
package render
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -470,13 +469,3 @@ func BenchmarkIntToStr(b *testing.B) {
|
||||||
IntToStr(v)
|
IntToStr(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helpers
|
|
||||||
|
|
||||||
func testTime() time.Time {
|
|
||||||
t, err := time.Parse(time.RFC3339, "2018-12-14T10:36:43.326972-07:00")
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("TestTime Failed", err)
|
|
||||||
}
|
|
||||||
return t
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -195,10 +195,6 @@ func (r RowEvents) FindIndex(id string) (int, bool) {
|
||||||
return 0, false
|
return 0, false
|
||||||
}
|
}
|
||||||
|
|
||||||
type tuple struct {
|
|
||||||
field, id string
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sort rows based on column index and order.
|
// Sort rows based on column index and order.
|
||||||
func (r RowEvents) Sort(ns string, sortCol int, isDuration, numCol, asc bool) {
|
func (r RowEvents) Sort(ns string, sortCol int, isDuration, numCol, asc bool) {
|
||||||
if sortCol == -1 {
|
if sortCol == -1 {
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,9 @@ package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
"github.com/derailed/k9s/internal/render"
|
"github.com/derailed/k9s/internal/render"
|
||||||
"k8s.io/apimachinery/pkg/util/duration"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// MaxyPad tracks uniform column padding.
|
// MaxyPad tracks uniform column padding.
|
||||||
|
|
@ -55,12 +53,3 @@ func Pad(s string, width int) string {
|
||||||
}
|
}
|
||||||
return s + strings.Repeat(" ", width-len(s))
|
return s + strings.Repeat(" ", width-len(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
func toAgeHuman(s string) string {
|
|
||||||
t, err := time.Parse(time.RFC3339Nano, s)
|
|
||||||
if err != nil {
|
|
||||||
return render.NAValue
|
|
||||||
}
|
|
||||||
|
|
||||||
return duration.HumanDuration(time.Since(t))
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,12 @@ import (
|
||||||
|
|
||||||
func TestMaxColumn(t *testing.T) {
|
func TestMaxColumn(t *testing.T) {
|
||||||
uu := map[string]struct {
|
uu := map[string]struct {
|
||||||
t render.TableData
|
t *render.TableData
|
||||||
s string
|
s string
|
||||||
e MaxyPad
|
e MaxyPad
|
||||||
}{
|
}{
|
||||||
"ascii col 0": {
|
"ascii col 0": {
|
||||||
render.TableData{
|
&render.TableData{
|
||||||
Header: render.Header{render.HeaderColumn{Name: "A"}, render.HeaderColumn{Name: "B"}},
|
Header: render.Header{render.HeaderColumn{Name: "A"}, render.HeaderColumn{Name: "B"}},
|
||||||
RowEvents: render.RowEvents{
|
RowEvents: render.RowEvents{
|
||||||
render.RowEvent{
|
render.RowEvent{
|
||||||
|
|
@ -33,7 +33,7 @@ func TestMaxColumn(t *testing.T) {
|
||||||
MaxyPad{6, 6},
|
MaxyPad{6, 6},
|
||||||
},
|
},
|
||||||
"ascii col 1": {
|
"ascii col 1": {
|
||||||
render.TableData{
|
&render.TableData{
|
||||||
Header: render.Header{render.HeaderColumn{Name: "A"}, render.HeaderColumn{Name: "B"}},
|
Header: render.Header{render.HeaderColumn{Name: "A"}, render.HeaderColumn{Name: "B"}},
|
||||||
RowEvents: render.RowEvents{
|
RowEvents: render.RowEvents{
|
||||||
render.RowEvent{
|
render.RowEvent{
|
||||||
|
|
@ -52,7 +52,7 @@ func TestMaxColumn(t *testing.T) {
|
||||||
MaxyPad{6, 6},
|
MaxyPad{6, 6},
|
||||||
},
|
},
|
||||||
"non_ascii": {
|
"non_ascii": {
|
||||||
render.TableData{
|
&render.TableData{
|
||||||
Header: render.Header{render.HeaderColumn{Name: "A"}, render.HeaderColumn{Name: "B"}},
|
Header: render.Header{render.HeaderColumn{Name: "A"}, render.HeaderColumn{Name: "B"}},
|
||||||
RowEvents: render.RowEvents{
|
RowEvents: render.RowEvents{
|
||||||
render.RowEvent{
|
render.RowEvent{
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ import (
|
||||||
"github.com/derailed/tview"
|
"github.com/derailed/tview"
|
||||||
"github.com/gdamore/tcell/v2"
|
"github.com/gdamore/tcell/v2"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
"golang.org/x/text/cases"
|
||||||
|
"golang.org/x/text/language"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
|
@ -421,7 +423,7 @@ func (t *Table) styleTitle() string {
|
||||||
rc--
|
rc--
|
||||||
}
|
}
|
||||||
|
|
||||||
base := strings.Title(t.gvr.R())
|
base := cases.Title(language.Und, cases.NoLower).String(t.gvr.R())
|
||||||
ns := t.GetModel().GetNamespace()
|
ns := t.GetModel().GetNamespace()
|
||||||
if client.IsClusterWide(ns) || ns == client.NotNamespaced {
|
if client.IsClusterWide(ns) || ns == client.NotNamespaced {
|
||||||
ns = client.NamespaceAll
|
ns = client.NamespaceAll
|
||||||
|
|
|
||||||
|
|
@ -367,7 +367,7 @@ func asResource(r config.Limits) v1.ResourceRequirements {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func pipe(ctx context.Context, opts shellOpts, cmds ...*exec.Cmd) error {
|
func pipe(_ context.Context, opts shellOpts, cmds ...*exec.Cmd) error {
|
||||||
if len(cmds) == 0 {
|
if len(cmds) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/derailed/k9s/internal/render"
|
"github.com/derailed/k9s/internal/render"
|
||||||
"github.com/derailed/k9s/internal/ui"
|
"github.com/derailed/k9s/internal/ui"
|
||||||
"github.com/gdamore/tcell/v2"
|
"github.com/gdamore/tcell/v2"
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Helm represents a helm chart view.
|
// Helm represents a helm chart view.
|
||||||
|
|
@ -66,7 +67,10 @@ func (c *Helm) getValsCmd() func(evt *tcell.EventKey) *tcell.EventKey {
|
||||||
|
|
||||||
func (c *Helm) toggleValuesCmd(evt *tcell.EventKey) *tcell.EventKey {
|
func (c *Helm) toggleValuesCmd(evt *tcell.EventKey) *tcell.EventKey {
|
||||||
c.Values.ToggleValues()
|
c.Values.ToggleValues()
|
||||||
c.Values.Refresh(c.defaultCtx())
|
if err := c.Values.Refresh(c.defaultCtx()); err != nil {
|
||||||
|
log.Error().Err(err).Msgf("helm refresh failed")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
c.App().Flash().Infof("Values toggled")
|
c.App().Flash().Infof("Values toggled")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,10 +58,6 @@ func NewLog(gvr client.GVR, opts *dao.LogOptions) *Log {
|
||||||
return &l
|
return &l
|
||||||
}
|
}
|
||||||
|
|
||||||
func logChan() dao.LogChan {
|
|
||||||
return make(dao.LogChan, 2)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Init initializes the viewer.
|
// Init initializes the viewer.
|
||||||
func (l *Log) Init(ctx context.Context) (err error) {
|
func (l *Log) Init(ctx context.Context) (err error) {
|
||||||
if l.app, err = extractApp(ctx); err != nil {
|
if l.app, err = extractApp(ctx); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -154,13 +154,6 @@ func (p *Pod) showNode(evt *tcell.EventKey) *tcell.EventKey {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func nodeContext(path string) ContextFunc {
|
|
||||||
return func(ctx context.Context) context.Context {
|
|
||||||
ctx = context.WithValue(ctx, internal.KeyPath, path)
|
|
||||||
return ctx
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Pod) showPFCmd(evt *tcell.EventKey) *tcell.EventKey {
|
func (p *Pod) showPFCmd(evt *tcell.EventKey) *tcell.EventKey {
|
||||||
path := p.GetTable().GetSelectedItem()
|
path := p.GetTable().GetSelectedItem()
|
||||||
if path == "" {
|
if path == "" {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/derailed/k9s/internal"
|
"github.com/derailed/k9s/internal"
|
||||||
"github.com/derailed/k9s/internal/client"
|
"github.com/derailed/k9s/internal/client"
|
||||||
|
|
@ -16,6 +15,8 @@ import (
|
||||||
"github.com/derailed/k9s/internal/ui"
|
"github.com/derailed/k9s/internal/ui"
|
||||||
"github.com/derailed/tview"
|
"github.com/derailed/tview"
|
||||||
"github.com/gdamore/tcell/v2"
|
"github.com/gdamore/tcell/v2"
|
||||||
|
"golang.org/x/text/cases"
|
||||||
|
"golang.org/x/text/language"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Graphable represents a graphic component.
|
// Graphable represents a graphic component.
|
||||||
|
|
@ -162,7 +163,7 @@ func (p *Pulse) PulseChanged(c *health.Check) {
|
||||||
case "cpu":
|
case "cpu":
|
||||||
perc := client.ToPercentage(c.Tally(health.S1), c.Tally(health.S2))
|
perc := client.ToPercentage(c.Tally(health.S1), c.Tally(health.S2))
|
||||||
v.SetLegend(fmt.Sprintf(cpuFmt,
|
v.SetLegend(fmt.Sprintf(cpuFmt,
|
||||||
strings.Title(gvr.R()),
|
cases.Title(language.Und, cases.NoLower).String(gvr.R()),
|
||||||
p.app.Config.K9s.Thresholds.SeverityColor("cpu", perc),
|
p.app.Config.K9s.Thresholds.SeverityColor("cpu", perc),
|
||||||
render.PrintPerc(perc),
|
render.PrintPerc(perc),
|
||||||
nn[0],
|
nn[0],
|
||||||
|
|
@ -173,7 +174,7 @@ func (p *Pulse) PulseChanged(c *health.Check) {
|
||||||
case "mem":
|
case "mem":
|
||||||
perc := client.ToPercentage(c.Tally(health.S1), c.Tally(health.S2))
|
perc := client.ToPercentage(c.Tally(health.S1), c.Tally(health.S2))
|
||||||
v.SetLegend(fmt.Sprintf(memFmt,
|
v.SetLegend(fmt.Sprintf(memFmt,
|
||||||
strings.Title(gvr.R()),
|
cases.Title(language.Und, cases.NoLower).String(gvr.R()),
|
||||||
p.app.Config.K9s.Thresholds.SeverityColor("memory", perc),
|
p.app.Config.K9s.Thresholds.SeverityColor("memory", perc),
|
||||||
render.PrintPerc(perc),
|
render.PrintPerc(perc),
|
||||||
nn[0],
|
nn[0],
|
||||||
|
|
@ -183,7 +184,7 @@ func (p *Pulse) PulseChanged(c *health.Check) {
|
||||||
))
|
))
|
||||||
default:
|
default:
|
||||||
v.SetLegend(fmt.Sprintf(genFmat,
|
v.SetLegend(fmt.Sprintf(genFmat,
|
||||||
strings.Title(gvr.R()),
|
cases.Title(language.Und, cases.NoLower).String(gvr.R()),
|
||||||
nn[0],
|
nn[0],
|
||||||
c.Tally(health.S1),
|
c.Tally(health.S1),
|
||||||
nn[1],
|
nn[1],
|
||||||
|
|
@ -206,7 +207,7 @@ func (p *Pulse) bindKeys() {
|
||||||
})
|
})
|
||||||
|
|
||||||
for i, v := range p.charts {
|
for i, v := range p.charts {
|
||||||
t := strings.Title(client.NewGVR(v.ID()).R())
|
t := cases.Title(language.Und, cases.NoLower).String(client.NewGVR(v.ID()).R())
|
||||||
p.actions[tcell.Key(ui.NumKeys[i])] = ui.NewKeyAction(t, p.sparkFocusCmd(i), true)
|
p.actions[tcell.Key(ui.NumKeys[i])] = ui.NewKeyAction(t, p.sparkFocusCmd(i), true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -340,7 +341,7 @@ func (p *Pulse) makeSP(loc image.Point, span image.Point, gvr string) *tchart.Sp
|
||||||
} else {
|
} else {
|
||||||
s.SetSeriesColors(p.app.Styles.Charts().DefaultChartColors.Colors()...)
|
s.SetSeriesColors(p.app.Styles.Charts().DefaultChartColors.Colors()...)
|
||||||
}
|
}
|
||||||
s.SetLegend(fmt.Sprintf(" %s ", strings.Title(client.NewGVR(gvr).R())))
|
s.SetLegend(fmt.Sprintf(" %s ", cases.Title(language.Und, cases.NoLower).String(client.NewGVR(gvr).R())))
|
||||||
s.SetInputCapture(p.keyboard)
|
s.SetInputCapture(p.keyboard)
|
||||||
s.SetMultiSeries(true)
|
s.SetMultiSeries(true)
|
||||||
p.AddItem(s, loc.X, loc.Y, span.X, span.Y, 0, 0, true)
|
p.AddItem(s, loc.X, loc.Y, span.X, span.Y, 0, 0, true)
|
||||||
|
|
@ -358,7 +359,7 @@ func (p *Pulse) makeGA(loc image.Point, span image.Point, gvr string) *tchart.Ga
|
||||||
} else {
|
} else {
|
||||||
g.SetSeriesColors(p.app.Styles.Charts().DefaultDialColors.Colors()...)
|
g.SetSeriesColors(p.app.Styles.Charts().DefaultDialColors.Colors()...)
|
||||||
}
|
}
|
||||||
g.SetLegend(fmt.Sprintf(" %s ", strings.Title(client.NewGVR(gvr).R())))
|
g.SetLegend(fmt.Sprintf(" %s ", cases.Title(language.Und, cases.NoLower).String(client.NewGVR(gvr).R())))
|
||||||
g.SetInputCapture(p.keyboard)
|
g.SetInputCapture(p.keyboard)
|
||||||
p.AddItem(g, loc.X, loc.Y, span.X, span.Y, 0, 0, true)
|
p.AddItem(g, loc.X, loc.Y, span.X, span.Y, 0, 0, true)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ import (
|
||||||
"github.com/derailed/tview"
|
"github.com/derailed/tview"
|
||||||
"github.com/gdamore/tcell/v2"
|
"github.com/gdamore/tcell/v2"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
"golang.org/x/text/cases"
|
||||||
|
"golang.org/x/text/language"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -65,7 +67,7 @@ func (s *Sanitizer) Init(ctx context.Context) error {
|
||||||
s.SetBorderColor(s.app.Styles.Frame().Border.FgColor.Color())
|
s.SetBorderColor(s.app.Styles.Frame().Border.FgColor.Color())
|
||||||
s.SetBorderFocusColor(s.app.Styles.Frame().Border.FocusColor.Color())
|
s.SetBorderFocusColor(s.app.Styles.Frame().Border.FocusColor.Color())
|
||||||
s.SetGraphicsColor(s.app.Styles.Xray().GraphicColor.Color())
|
s.SetGraphicsColor(s.app.Styles.Xray().GraphicColor.Color())
|
||||||
s.SetTitle(strings.Title(s.gvr.R()))
|
s.SetTitle(cases.Title(language.Und, cases.NoLower).String(s.gvr.R()))
|
||||||
|
|
||||||
s.model.SetNamespace(client.CleanseNamespace(s.app.Config.ActiveNamespace()))
|
s.model.SetNamespace(client.CleanseNamespace(s.app.Config.ActiveNamespace()))
|
||||||
s.model.AddListener(s)
|
s.model.AddListener(s)
|
||||||
|
|
@ -401,7 +403,7 @@ func (s *Sanitizer) UpdateTitle() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Sanitizer) styleTitle() string {
|
func (s *Sanitizer) styleTitle() string {
|
||||||
base := strings.Title(s.gvr.R())
|
base := cases.Title(language.Und, cases.NoLower).String(s.gvr.R())
|
||||||
ns := s.model.GetNamespace()
|
ns := s.model.GetNamespace()
|
||||||
if client.IsAllNamespaces(ns) {
|
if client.IsAllNamespaces(ns) {
|
||||||
ns = client.NamespaceAll
|
ns = client.NamespaceAll
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ import (
|
||||||
"github.com/gdamore/tcell/v2"
|
"github.com/gdamore/tcell/v2"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/sahilm/fuzzy"
|
"github.com/sahilm/fuzzy"
|
||||||
|
"golang.org/x/text/cases"
|
||||||
|
"golang.org/x/text/language"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -72,7 +74,7 @@ func (x *Xray) Init(ctx context.Context) error {
|
||||||
x.SetBorderColor(x.app.Styles.Xray().FgColor.Color())
|
x.SetBorderColor(x.app.Styles.Xray().FgColor.Color())
|
||||||
x.SetBorderFocusColor(x.app.Styles.Frame().Border.FocusColor.Color())
|
x.SetBorderFocusColor(x.app.Styles.Frame().Border.FocusColor.Color())
|
||||||
x.SetGraphicsColor(x.app.Styles.Xray().GraphicColor.Color())
|
x.SetGraphicsColor(x.app.Styles.Xray().GraphicColor.Color())
|
||||||
x.SetTitle(fmt.Sprintf(" %s-%s ", xrayTitle, strings.Title(x.gvr.R())))
|
x.SetTitle(fmt.Sprintf(" %s-%s ", xrayTitle, cases.Title(language.Und, cases.NoLower).String(x.gvr.R())))
|
||||||
|
|
||||||
x.model.SetRefreshRate(time.Duration(x.app.Config.K9s.GetRefreshRate()) * time.Second)
|
x.model.SetRefreshRate(time.Duration(x.app.Config.K9s.GetRefreshRate()) * time.Second)
|
||||||
x.model.SetNamespace(client.CleanseNamespace(x.app.Config.ActiveNamespace()))
|
x.model.SetNamespace(client.CleanseNamespace(x.app.Config.ActiveNamespace()))
|
||||||
|
|
@ -632,7 +634,7 @@ func (x *Xray) UpdateTitle() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Xray) styleTitle() string {
|
func (x *Xray) styleTitle() string {
|
||||||
base := fmt.Sprintf("%s-%s", xrayTitle, strings.Title(x.gvr.R()))
|
base := fmt.Sprintf("%s-%s", xrayTitle, cases.Title(language.Und, cases.NoLower).String(x.gvr.R()))
|
||||||
ns := x.model.GetNamespace()
|
ns := x.model.GetNamespace()
|
||||||
if client.IsAllNamespaces(ns) {
|
if client.IsAllNamespaces(ns) {
|
||||||
ns = client.NamespaceAll
|
ns = client.NamespaceAll
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue