fix shell issue + bugz

mine
derailed 2021-05-03 23:39:54 -06:00
commit 739f495daa
5 changed files with 183 additions and 30 deletions

View File

@ -11,8 +11,9 @@ for changes and offers subsequent commands to interact with your observed resour
## Note... ## Note...
As you may know K9s is not pimped out by a big corporation with deep pockets. It is a complex OSS project that demands a lot of my time to maintain. K9s will remain OSS and free. That said if you feel, K9s makes your day to day Kubernetes journey a bit brighter, please consider sponsoring this repo or purchasing a [K9sAlpha license](https://k9salpha.io). As you may know k9s is not pimped out by a big corporation with deep pockets. It is a complex OSS project that demands a lot of my time to maintain and support. K9s will always remain OSS and therefore free! That said if you feel, k9s makes your day to day Kubernetes journey a tad brighter, please consider sponsoring us or purchase a [K9sAlpha license](https://k9salpha.io). Your donations will go a long way in keeping our servers lights on and beers in our fridge!
This does go a long way in keeping us our servers lights on and beers in our fridge! Thank you!!
**Thank you!**
--- ---

View File

@ -0,0 +1,29 @@
<img src="https://raw.githubusercontent.com/derailed/k9s/master/assets/k9s_small.png" align="right" width="200" height="auto"/>
# Release v0.24.9
## Notes
Thank you to all that contributed with flushing out issues and enhancements for K9s! I'll try to mark some of these issues as fixed. But if you don't mind grab the latest rev and see if we're happier with some of the fixes! If you've filed an issue please help me verify and close. Your support, kindness and awesome suggestions to make K9s better are as ever very much noted and appreciated!
If you feel K9s is helping your Kubernetes journey, please consider joining our [sponsorhip program](https://github.com/sponsors/derailed) and/or make some noise on social! [@kitesurfer](https://twitter.com/kitesurfer)
On Slack? Please join us [K9slackers](https://join.slack.com/t/k9sers/shared_invite/enQtOTA5MDEyNzI5MTU0LWQ1ZGI3MzliYzZhZWEyNzYxYzA3NjE0YTk1YmFmNzViZjIyNzhkZGI0MmJjYzhlNjdlMGJhYzE2ZGU1NjkyNTM)
## Maintenance Release!
---
## Resolved Issues
* [Issue #1111](https://github.com/derailed/k9s/issues/1111) -A switch doesn't work as advertised
* [Issue #1109](https://github.com/derailed/k9s/issues/1109) 0.24.8 edit needs an extra keystroke to process. (Crossing fingers AND toes!!)
* [Issue #1104](https://github.com/derailed/k9s/issues/1104) Configure args for shellPod
## Resolved PRs
* [PR #1103](https://github.com/derailed/k9s/pull/1103) Dynamically load style for help. Big Thanks To [Louis Garman](https://github.com/leg100)
---
<img src="https://raw.githubusercontent.com/derailed/k9s/master/assets/imhotep_logo.png" width="32" height="auto"/> © 2020 Imhotep Software LLC. All materials licensed under [Apache v2.0](http://www.apache.org/licenses/LICENSE-2.0)

View File

@ -44,6 +44,13 @@ func NewMenu(styles *config.Styles) *Menu {
func (m *Menu) StylesChanged(s *config.Styles) { func (m *Menu) StylesChanged(s *config.Styles) {
m.styles = s m.styles = s
m.SetBackgroundColor(s.BgColor()) m.SetBackgroundColor(s.BgColor())
for row := 0; row < m.GetRowCount(); row++ {
for col := 0; col < m.GetColumnCount(); col++ {
if c := m.GetCell(row, col); c != nil {
c.BackgroundColor = s.BgColor()
}
}
}
} }
// StackPushed notifies a component was added. // StackPushed notifies a component was added.

View File

@ -43,13 +43,6 @@ func NewHelp(app *App) *Help {
} }
} }
// StylesChanged notifies skin changed.
func (h *Help) StylesChanged(s *config.Styles) {
h.styles = s
h.SetBackgroundColor(s.BgColor())
h.build()
}
// Init initializes the component. // Init initializes the component.
func (h *Help) Init(ctx context.Context) error { func (h *Help) Init(ctx context.Context) error {
if err := h.Table.Init(ctx); err != nil { if err := h.Table.Init(ctx); err != nil {
@ -60,13 +53,21 @@ func (h *Help) Init(ctx context.Context) error {
h.SetBorder(true) h.SetBorder(true)
h.SetBorderPadding(0, 0, 1, 1) h.SetBorderPadding(0, 0, 1, 1)
h.bindKeys() h.bindKeys()
h.styles = h.App().Styles
h.App().Styles.AddListener(h)
h.build() h.build()
h.app.Styles.AddListener(h)
h.StylesChanged(h.app.Styles)
return nil return nil
} }
// StylesChanged notifies skin changed.
func (h *Help) StylesChanged(s *config.Styles) {
log.Debug().Msgf("CHANGED!")
h.styles = s
h.SetBackgroundColor(s.BgColor())
h.updateStyle()
}
func (h *Help) bindKeys() { func (h *Help) bindKeys() {
h.Actions().Delete(ui.KeySpace, tcell.KeyCtrlSpace, tcell.KeyCtrlS, ui.KeySlash) h.Actions().Delete(ui.KeySpace, tcell.KeyCtrlSpace, tcell.KeyCtrlS, ui.KeySlash)
h.Actions().Set(ui.KeyActions{ h.Actions().Set(ui.KeyActions{
@ -300,9 +301,9 @@ func (h *Help) addSection(c int, title string, hh model.MenuHints) {
for _, hint := range hh { for _, hint := range hh {
col := c col := c
h.SetCell(row, col, h.keyCell(hint.Mnemonic, h.maxKey)) h.SetCell(row, col, padCellWithRef(toMnemonic(hint.Mnemonic), h.maxKey, hint.Mnemonic))
col++ col++
h.SetCell(row, col, h.infoCell(hint.Description, h.maxDesc)) h.SetCell(row, col, padCell(hint.Description, h.maxDesc))
row++ row++
} }
@ -319,6 +320,36 @@ func (h *Help) addSection(c int, title string, hh model.MenuHints) {
} }
} }
func (h *Help) updateStyle() {
var (
style = tcell.StyleDefault.Background(h.styles.K9s.Help.BgColor.Color())
key = style.Foreground(h.styles.K9s.Help.KeyColor.Color()).Bold(true)
numKey = style.Foreground(h.app.Styles.K9s.Help.NumKeyColor.Color()).Bold(true)
info = style.Foreground(h.app.Styles.K9s.Help.FgColor.Color())
heading = style.Foreground(h.app.Styles.K9s.Help.SectionColor.Color())
)
for col := 0; col < h.GetColumnCount(); col++ {
for row := 0; row < h.GetRowCount(); row++ {
c := h.GetCell(row, col)
if c == nil {
continue
}
switch {
case row == 0:
c.SetStyle(heading)
case col%2 != 0:
c.SetStyle(info)
default:
if _, err := strconv.Atoi(extractRef(c)); err == nil {
c.SetStyle(numKey)
continue
}
c.SetStyle(key)
}
}
}
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Helpers... // Helpers...
@ -330,6 +361,14 @@ func toMnemonic(s string) string {
return "<" + keyConv(strings.ToLower(s)) + ">" return "<" + keyConv(strings.ToLower(s)) + ">"
} }
func extractRef(c *tview.TableCell) string {
if ref, ok := c.GetReference().(string); ok {
return ref
}
return c.Text
}
func keyConv(s string) string { func keyConv(s string) string {
if !strings.Contains(s, "alt") { if !strings.Contains(s, "alt") {
return s return s
@ -352,23 +391,8 @@ func (h *Help) titleCell(title string) *tview.TableCell {
return c return c
} }
func (h *Help) keyCell(k string, width int) *tview.TableCell { func padCellWithRef(s string, width int, ref interface{}) *tview.TableCell {
c := padCell(toMnemonic(k), width) return padCell(s, width).SetReference(ref)
if _, err := strconv.Atoi(k); err != nil {
c.SetTextColor(h.styles.K9s.Help.KeyColor.Color())
} else {
c.SetTextColor(h.styles.K9s.Help.NumKeyColor.Color())
}
c.SetAttributes(tcell.AttrBold)
return c
}
func (h *Help) infoCell(info string, width int) *tview.TableCell {
c := padCell(info, width)
c.SetTextColor(h.styles.K9s.Help.FgColor.Color())
return c
} }
func padCell(s string, width int) *tview.TableCell { func padCell(s string, width int) *tview.TableCell {

92
skins/solarized_light.yml Normal file
View File

@ -0,0 +1,92 @@
# K9s Solarized Light Skin Contributed by [@leg100](louisgarman@gmail.com)
foreground: &foreground "#657b83"
background: &background "#fdf6e3"
current_line: &current_line "#eee8d5"
selection: &selection "#eee8d5"
comment: &comment "#93a1a1"
cyan: &cyan "#2aa198"
green: &green "#859900"
yellow: &yellow "#b58900"
orange: &orange "#cb4b16"
magenta: &magenta "#d33682"
blue: &blue "#268bd2"
red: &red "#dc322f"
k9s:
body:
fgColor: *foreground
bgColor: *background
logoColor: *blue
info:
fgColor: *magenta
sectionColor: *foreground
dialog:
fgColor: *foreground
bgColor: *background
buttonFgColor: *foreground
buttonBgColor: *magenta
buttonFocusFgColor: white
buttonFocusBgColor: *cyan
labelFgColor: *orange
fieldFgColor: *foreground
frame:
border:
fgColor: *selection
focusColor: *foreground
menu:
fgColor: *foreground
keyColor: *magenta
numKeyColor: *magenta
crumbs:
fgColor: white
bgColor: *cyan
activeColor: *yellow
status:
newColor: *cyan
modifyColor: *blue
addColor: *green
errorColor: *red
highlightcolor: *orange
killColor: *comment
completedColor: *comment
title:
fgColor: *foreground
bgColor: *background
highlightColor: *blue
counterColor: *magenta
filterColor: *magenta
views:
charts:
bgColor: default
defaultDialColors:
- *blue
- *red
defaultChartColors:
- *blue
- *red
table:
fgColor: *foreground
bgColor: *background
cursorFgColor: white
cursorBgColor: *background
markColor: darkgoldenrod
header:
fgColor: *foreground
bgColor: *background
sorterColor: *cyan
xray:
fgColor: *foreground
bgColor: *background
cursorColor: *current_line
graphicColor: *blue
showIcons: false
yaml:
keyColor: *magenta
colonColor: *blue
valueColor: *foreground
logs:
fgColor: *foreground
bgColor: *background
indicator:
fgColor: *foreground
bgColor: *selection