Skip to content

Commit

Permalink
feat: add autoRefresh config field (derailed#2256) (derailed#2257)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
wfrced and Artem Gorbatiuk authored Nov 8, 2023
1 parent 8155384 commit e28efdf
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -376,6 +377,7 @@ var expectedConfig = `k9s:
`

var resetConfig = `k9s:
liveViewAutoRefresh: true
refreshRate: 2
maxConnRetry: 5
enableMouse: false
Expand Down
1 change: 1 addition & 0 deletions internal/config/k9s.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
1 change: 1 addition & 0 deletions internal/config/testdata/k9s.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
k9s:
liveViewAutoRefresh: true
refreshRate: 2
readOnly: false
logger:
Expand Down
1 change: 1 addition & 0 deletions internal/view/live_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit e28efdf

Please sign in to comment.