commit
e78ad92f0f
|
|
@ -266,6 +266,8 @@ K9s uses aliases to navigate most K8s resources.
|
||||||
enableMouse: false
|
enableMouse: false
|
||||||
# Set to true to hide K9s header. Default false
|
# Set to true to hide K9s header. Default false
|
||||||
headless: false
|
headless: false
|
||||||
|
# Set to true to hide K9s footer. Default false
|
||||||
|
crumbsless: false
|
||||||
# Indicates whether modification commands like delete/kill/edit are disabled. Default is false
|
# Indicates whether modification commands like delete/kill/edit are disabled. Default is false
|
||||||
readOnly: false
|
readOnly: false
|
||||||
# Toggles icons display as not all terminal support these chars.
|
# Toggles icons display as not all terminal support these chars.
|
||||||
|
|
|
||||||
|
|
@ -217,6 +217,12 @@ func initK9sFlags() {
|
||||||
false,
|
false,
|
||||||
"Disable all commands that modify the cluster",
|
"Disable all commands that modify the cluster",
|
||||||
)
|
)
|
||||||
|
rootCmd.Flags().BoolVar(
|
||||||
|
k9sFlags.Crumbsless,
|
||||||
|
"crumbsless",
|
||||||
|
false,
|
||||||
|
"Turn K9s crumbs off",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func initK8sFlags() {
|
func initK8sFlags() {
|
||||||
|
|
|
||||||
|
|
@ -263,6 +263,7 @@ var expectedConfig = `k9s:
|
||||||
refreshRate: 100
|
refreshRate: 100
|
||||||
enableMouse: false
|
enableMouse: false
|
||||||
headless: false
|
headless: false
|
||||||
|
crumbsless: false
|
||||||
readOnly: true
|
readOnly: true
|
||||||
noIcons: false
|
noIcons: false
|
||||||
logger:
|
logger:
|
||||||
|
|
@ -344,6 +345,7 @@ var resetConfig = `k9s:
|
||||||
refreshRate: 2
|
refreshRate: 2
|
||||||
enableMouse: false
|
enableMouse: false
|
||||||
headless: false
|
headless: false
|
||||||
|
crumbsless: false
|
||||||
readOnly: false
|
readOnly: false
|
||||||
noIcons: false
|
noIcons: false
|
||||||
logger:
|
logger:
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ type Flags struct {
|
||||||
Command *string
|
Command *string
|
||||||
AllNamespaces *bool
|
AllNamespaces *bool
|
||||||
ReadOnly *bool
|
ReadOnly *bool
|
||||||
|
Crumbsless *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFlags returns new configuration flags.
|
// NewFlags returns new configuration flags.
|
||||||
|
|
@ -30,6 +31,7 @@ func NewFlags() *Flags {
|
||||||
Command: strPtr(DefaultCommand),
|
Command: strPtr(DefaultCommand),
|
||||||
AllNamespaces: boolPtr(false),
|
AllNamespaces: boolPtr(false),
|
||||||
ReadOnly: boolPtr(false),
|
ReadOnly: boolPtr(false),
|
||||||
|
Crumbsless: boolPtr(false),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ type K9s struct {
|
||||||
RefreshRate int `yaml:"refreshRate"`
|
RefreshRate int `yaml:"refreshRate"`
|
||||||
EnableMouse bool `yaml:"enableMouse"`
|
EnableMouse bool `yaml:"enableMouse"`
|
||||||
Headless bool `yaml:"headless"`
|
Headless bool `yaml:"headless"`
|
||||||
|
Crumbsless bool `yaml:"crumbsless"`
|
||||||
ReadOnly bool `yaml:"readOnly"`
|
ReadOnly bool `yaml:"readOnly"`
|
||||||
NoIcons bool `yaml:"noIcons"`
|
NoIcons bool `yaml:"noIcons"`
|
||||||
Logger *Logger `yaml:"logger"`
|
Logger *Logger `yaml:"logger"`
|
||||||
|
|
@ -18,6 +19,7 @@ type K9s struct {
|
||||||
Thresholds Threshold `yaml:"thresholds"`
|
Thresholds Threshold `yaml:"thresholds"`
|
||||||
manualRefreshRate int
|
manualRefreshRate int
|
||||||
manualHeadless *bool
|
manualHeadless *bool
|
||||||
|
manualCrumbsless *bool
|
||||||
manualReadOnly *bool
|
manualReadOnly *bool
|
||||||
manualCommand *string
|
manualCommand *string
|
||||||
}
|
}
|
||||||
|
|
@ -42,6 +44,11 @@ func (k *K9s) OverrideHeadless(b bool) {
|
||||||
k.manualHeadless = &b
|
k.manualHeadless = &b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OverrideCrumbsless set the headlessness manually.
|
||||||
|
func (k *K9s) OverrideCrumbsless(b bool) {
|
||||||
|
k.manualCrumbsless = &b
|
||||||
|
}
|
||||||
|
|
||||||
// OverrideReadOnly set the readonly mode manually.
|
// OverrideReadOnly set the readonly mode manually.
|
||||||
func (k *K9s) OverrideReadOnly(b bool) {
|
func (k *K9s) OverrideReadOnly(b bool) {
|
||||||
k.manualReadOnly = &b
|
k.manualReadOnly = &b
|
||||||
|
|
@ -62,6 +69,16 @@ func (k *K9s) GetHeadless() bool {
|
||||||
return h
|
return h
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetCrumbsless returns crumbsless setting.
|
||||||
|
func (k *K9s) GetCrumbsless() bool {
|
||||||
|
h := k.Crumbsless
|
||||||
|
if k.manualCrumbsless != nil && *k.manualCrumbsless {
|
||||||
|
h = *k.manualCrumbsless
|
||||||
|
}
|
||||||
|
|
||||||
|
return h
|
||||||
|
}
|
||||||
|
|
||||||
// GetRefreshRate returns the current refresh rate.
|
// GetRefreshRate returns the current refresh rate.
|
||||||
func (k *K9s) GetRefreshRate() int {
|
func (k *K9s) GetRefreshRate() int {
|
||||||
rate := k.RefreshRate
|
rate := k.RefreshRate
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ type App struct {
|
||||||
filterHistory *model.History
|
filterHistory *model.History
|
||||||
conRetry int32
|
conRetry int32
|
||||||
showHeader bool
|
showHeader bool
|
||||||
|
showCrumbs bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewApp returns a K9s app instance.
|
// NewApp returns a K9s app instance.
|
||||||
|
|
@ -129,12 +130,12 @@ func (a *App) layout(ctx context.Context, version string) {
|
||||||
main := tview.NewFlex().SetDirection(tview.FlexRow)
|
main := tview.NewFlex().SetDirection(tview.FlexRow)
|
||||||
main.AddItem(a.statusIndicator(), 1, 1, false)
|
main.AddItem(a.statusIndicator(), 1, 1, false)
|
||||||
main.AddItem(a.Content, 0, 10, true)
|
main.AddItem(a.Content, 0, 10, true)
|
||||||
main.AddItem(a.Crumbs(), 1, 1, false)
|
|
||||||
main.AddItem(flash, 1, 1, false)
|
main.AddItem(flash, 1, 1, false)
|
||||||
|
|
||||||
a.Main.AddPage("main", main, true, false)
|
a.Main.AddPage("main", main, true, false)
|
||||||
a.Main.AddPage("splash", ui.NewSplash(a.Styles, version), true, true)
|
a.Main.AddPage("splash", ui.NewSplash(a.Styles, version), true, true)
|
||||||
a.toggleHeader(!a.Config.K9s.GetHeadless())
|
a.toggleHeader(!a.Config.K9s.GetHeadless())
|
||||||
|
a.toggleCrumbs(!a.Config.K9s.GetCrumbsless())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) initSignals() {
|
func (a *App) initSignals() {
|
||||||
|
|
@ -186,6 +187,7 @@ func (a *App) keyboard(evt *tcell.EventKey) *tcell.EventKey {
|
||||||
func (a *App) bindKeys() {
|
func (a *App) bindKeys() {
|
||||||
a.AddActions(ui.KeyActions{
|
a.AddActions(ui.KeyActions{
|
||||||
tcell.KeyCtrlE: ui.NewSharedKeyAction("ToggleHeader", a.toggleHeaderCmd, false),
|
tcell.KeyCtrlE: ui.NewSharedKeyAction("ToggleHeader", a.toggleHeaderCmd, false),
|
||||||
|
tcell.KeyCtrlT: ui.NewSharedKeyAction("toggleCrumbs", a.toggleCrumbsCmd, false),
|
||||||
ui.KeyHelp: ui.NewSharedKeyAction("Help", a.helpCmd, false),
|
ui.KeyHelp: ui.NewSharedKeyAction("Help", a.helpCmd, false),
|
||||||
tcell.KeyCtrlA: ui.NewSharedKeyAction("Aliases", a.aliasCmd, false),
|
tcell.KeyCtrlA: ui.NewSharedKeyAction("Aliases", a.aliasCmd, false),
|
||||||
tcell.KeyEnter: ui.NewKeyAction("Goto", a.gotoCmd, false),
|
tcell.KeyEnter: ui.NewKeyAction("Goto", a.gotoCmd, false),
|
||||||
|
|
@ -212,6 +214,19 @@ func (a *App) toggleHeader(flag bool) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *App) toggleCrumbs(flag bool) {
|
||||||
|
a.showCrumbs = flag
|
||||||
|
flex, ok := a.Main.GetPrimitive("main").(*tview.Flex)
|
||||||
|
if !ok {
|
||||||
|
log.Fatal().Msg("Expecting valid flex view")
|
||||||
|
}
|
||||||
|
if a.showCrumbs {
|
||||||
|
flex.AddItemAtIndex(2, a.Crumbs(), 1, 1, false)
|
||||||
|
} else {
|
||||||
|
flex.RemoveItemAtIndex(2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (a *App) buildHeader() tview.Primitive {
|
func (a *App) buildHeader() tview.Primitive {
|
||||||
header := tview.NewFlex()
|
header := tview.NewFlex()
|
||||||
header.SetBackgroundColor(a.Styles.BgColor())
|
header.SetBackgroundColor(a.Styles.BgColor())
|
||||||
|
|
@ -498,6 +513,19 @@ func (a *App) toggleHeaderCmd(evt *tcell.EventKey) *tcell.EventKey {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *App) toggleCrumbsCmd(evt *tcell.EventKey) *tcell.EventKey {
|
||||||
|
if a.Prompt().InCmdMode() {
|
||||||
|
return evt
|
||||||
|
}
|
||||||
|
|
||||||
|
a.QueueUpdateDraw(func() {
|
||||||
|
a.showCrumbs = !a.showCrumbs
|
||||||
|
a.toggleCrumbs(a.showCrumbs)
|
||||||
|
})
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (a *App) gotoCmd(evt *tcell.EventKey) *tcell.EventKey {
|
func (a *App) gotoCmd(evt *tcell.EventKey) *tcell.EventKey {
|
||||||
if a.CmdBuff().IsActive() && !a.CmdBuff().Empty() {
|
if a.CmdBuff().IsActive() && !a.CmdBuff().Empty() {
|
||||||
if err := a.gotoResource(a.GetCmd(), "", true); err != nil {
|
if err := a.gotoResource(a.GetCmd(), "", true); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -12,5 +12,5 @@ func TestAppNew(t *testing.T) {
|
||||||
a := view.NewApp(config.NewConfig(ks{}))
|
a := view.NewApp(config.NewConfig(ks{}))
|
||||||
a.Init("blee", 10)
|
a.Init("blee", 10)
|
||||||
|
|
||||||
assert.Equal(t, 9, len(a.GetActions()))
|
assert.Equal(t, 10, len(a.GetActions()))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue