feat: add autoRefresh config field (#2256) (#2257)

* feat: add autoRefresh config field

Add autoRefresh: true to config test scenarios
Update all instances of NewLiveView() to pass autoRefresh config value to LiveView

* fix: rename generic autoRefresh config field to liveViewAutoRefresh

* docs: document liveViewAutoRefresh config field

* fix: use app config for NewLiveView creation

---------

Co-authored-by: Artem Gorbatiuk <wfrced@gmail.com>
mine
Artem Gorbatiuk 2023-11-08 20:45:22 +01:00 committed by GitHub
parent 68afb3d9ef
commit a34d7ae6bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 0 deletions

View File

@ -319,6 +319,8 @@ K9s uses aliases to navigate most K8s resources.
```yaml
# $XDG_CONFIG_HOME/k9s/config.yml
k9s:
# Enable periodic refresh of resource browser windows. Default false
liveViewAutoRefresh: false
# Represents ui poll intervals. Default 2secs
refreshRate: 2
# Number of retries once the connection to the api-server is lost. Default 15.

View File

@ -277,6 +277,7 @@ func (m *mockSettings) ClusterNames() (map[string]struct{}, error) { return nil,
// Test Data...
var expectedConfig = `k9s:
liveViewAutoRefresh: true
refreshRate: 100
maxConnRetry: 5
enableMouse: false
@ -376,6 +377,7 @@ var expectedConfig = `k9s:
`
var resetConfig = `k9s:
liveViewAutoRefresh: true
refreshRate: 2
maxConnRetry: 5
enableMouse: false

View File

@ -11,6 +11,7 @@ const (
// K9s tracks K9s configuration options.
type K9s struct {
LiveViewAutoRefresh bool `yaml:"liveViewAutoRefresh"`
RefreshRate int `yaml:"refreshRate"`
MaxConnRetry int `yaml:"maxConnRetry"`
EnableMouse bool `yaml:"enableMouse"`

View File

@ -1,4 +1,5 @@
k9s:
liveViewAutoRefresh: true
refreshRate: 2
readOnly: false
logger:

View File

@ -48,6 +48,7 @@ func NewLiveView(app *App, title string, m model.ResourceViewer) *LiveView {
maxRegions: 0,
cmdBuff: model.NewFishBuff('/', model.FilterBuffer),
model: m,
autoRefresh: app.Config.K9s.LiveViewAutoRefresh,
}
v.AddItem(v.text, 0, 1, true)