diff --git a/internal/config/json/schemas/k9s.json b/internal/config/json/schemas/k9s.json index e6fc4d83cf..844a6b6d33 100644 --- a/internal/config/json/schemas/k9s.json +++ b/internal/config/json/schemas/k9s.json @@ -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" }, diff --git a/internal/config/k9s.go b/internal/config/k9s.go index 5cc2ec411b..dc026c9445 100644 --- a/internal/config/k9s.go +++ b/internal/config/k9s.go @@ -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"` @@ -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(), @@ -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 @@ -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 { diff --git a/internal/config/types.go b/internal/config/types.go index 6938e55585..81e6871b00 100644 --- a/internal/config/types.go +++ b/internal/config/types.go @@ -6,6 +6,7 @@ package config const ( defaultRefreshRate = 2 defaultMaxConnRetry = 5 + defaultFlashDelay = 3 ) // UI tracks ui specific configs. diff --git a/internal/model/flash.go b/internal/model/flash.go index d4bb7c8dc1..0a71ba5c9e 100644 --- a/internal/model/flash.go +++ b/internal/model/flash.go @@ -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. diff --git a/internal/ui/app.go b/internal/ui/app.go index 16f9ebcfcf..e9d7c8974a 100644 --- a/internal/ui/app.go +++ b/internal/ui/app.go @@ -6,6 +6,7 @@ package ui import ( "os" "sync" + "time" "github.com/derailed/k9s/internal/client" "github.com/derailed/k9s/internal/config" @@ -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), }