Skip to content

Make flash delay configurable from config.yaml #3144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/config/json/schemas/k9s.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"screenDumpDir": {"type": "string"},
"refreshRate": { "type": "integer" },
"maxConnRetry": { "type": "integer" },
"flashDelay": { "type": "integer" },
"readOnly": { "type": "boolean" },
"noExitOnCtrlC": { "type": "boolean" },
"skipLatestRevCheck": { "type": "boolean" },
Expand Down
6 changes: 6 additions & 0 deletions internal/config/k9s.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type K9s struct {
ScreenDumpDir string `json:"screenDumpDir" yaml:"screenDumpDir,omitempty"`
RefreshRate int `json:"refreshRate" yaml:"refreshRate"`
MaxConnRetry int `json:"maxConnRetry" yaml:"maxConnRetry"`
FlashDelay int `json:"flashDelay" yaml:"flashDelay"`
ReadOnly bool `json:"readOnly" yaml:"readOnly"`
NoExitOnCtrlC bool `json:"noExitOnCtrlC" yaml:"noExitOnCtrlC"`
UI UI `json:"ui" yaml:"ui"`
Expand Down Expand Up @@ -53,6 +54,7 @@ func NewK9s(conn client.Connection, ks data.KubeSettings) *K9s {
return &K9s{
RefreshRate: defaultRefreshRate,
MaxConnRetry: defaultMaxConnRetry,
FlashDelay: defaultFlashDelay,
ScreenDumpDir: AppDumpsDir,
Logger: NewLogger(),
Thresholds: NewThreshold(),
Expand Down Expand Up @@ -99,6 +101,7 @@ func (k *K9s) Merge(k1 *K9s) {
k.ScreenDumpDir = k1.ScreenDumpDir
k.RefreshRate = k1.RefreshRate
k.MaxConnRetry = k1.MaxConnRetry
k.FlashDelay = k1.FlashDelay
k.ReadOnly = k1.ReadOnly
k.NoExitOnCtrlC = k1.NoExitOnCtrlC
k.UI = k1.UI
Expand Down Expand Up @@ -347,6 +350,9 @@ func (k *K9s) Validate(c client.Connection, ks data.KubeSettings) {
if k.MaxConnRetry <= 0 {
k.MaxConnRetry = defaultMaxConnRetry
}
if k.FlashDelay <= 0 {
k.FlashDelay = defaultFlashDelay
}

if k.getActiveConfig() == nil {
if n, err := ks.CurrentContextName(); err == nil {
Expand Down
1 change: 1 addition & 0 deletions internal/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package config
const (
defaultRefreshRate = 2
defaultMaxConnRetry = 5
defaultFlashDelay = 3
)

// UI tracks ui specific configs.
Expand Down
3 changes: 0 additions & 3 deletions internal/model/flash.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import (
)

const (
// DefaultFlashDelay sets the flash clear delay.
DefaultFlashDelay = 3 * time.Second

// FlashInfo represents an info message.
FlashInfo FlashLevel = iota
// FlashWarn represents an warning message.
Expand Down
3 changes: 2 additions & 1 deletion internal/ui/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package ui
import (
"os"
"sync"
"time"

"github.com/derailed/k9s/internal/client"
"github.com/derailed/k9s/internal/config"
Expand Down Expand Up @@ -36,7 +37,7 @@ func NewApp(cfg *config.Config, context string) *App {
actions: NewKeyActions(),
Configurator: Configurator{Config: cfg, Styles: config.NewStyles()},
Main: NewPages(),
flash: model.NewFlash(model.DefaultFlashDelay),
flash: model.NewFlash(time.Duration(cfg.K9s.FlashDelay) * time.Second),
cmdBuff: model.NewFishBuff(':', model.CommandBuffer),
}

Expand Down
Loading