Feature/default_view (#2866)

* initialView

* Removed log msg

* fix: tests

* fix: rename to defaultView

* docs: add defaultView setting to README
mine
Ümüt Özalp 2025-04-19 19:58:51 +02:00 committed by GitHub
parent fbd2a0250a
commit c2694ee3e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 13 additions and 0 deletions

View File

@ -415,6 +415,8 @@ You can now override the context portForward default address configuration by se
maxConnRetry: 5
# Indicates whether modification commands like delete/kill/edit are disabled. Default is false
readOnly: false
# This setting allows users to specify the default view, but it is not set by default.
defaultView: ""
# Toggles whether k9s should exit when CTRL-C is pressed. When set to true, you will need to exit k9s via the :quit command. Default is false.
noExitOnCtrlC: false
#UI settings

View File

@ -113,6 +113,10 @@ func run(*cobra.Command, []string) error {
slog.Warn("Fail to load global/context configuration", slogs.Error, err)
}
app := view.NewApp(cfg)
if app.Config.K9s.DefaultView != "" {
app.Config.SetActiveView(app.Config.K9s.DefaultView)
}
if err := app.Init(version, *k9sFlags.RefreshRate); err != nil {
return err
}

View File

@ -15,6 +15,7 @@
"noExitOnCtrlC": { "type": "boolean" },
"skipLatestRevCheck": { "type": "boolean" },
"disablePodCounting": { "type": "boolean" },
"defaultView": { "type": "string" },
"portForwardAddress": { "type": "string" },
"ui": {
"type": "object",

View File

@ -35,6 +35,7 @@ type K9s struct {
ImageScans ImageScans `json:"imageScans" yaml:"imageScans"`
Logger Logger `json:"logger" yaml:"logger"`
Thresholds Threshold `json:"thresholds" yaml:"thresholds"`
DefaultView string `json:"defaultView" yaml:"defaultView"`
manualRefreshRate int
manualReadOnly *bool
manualCommand *string
@ -113,6 +114,7 @@ func (k *K9s) Merge(k1 *K9s) {
}
k.LiveViewAutoRefresh = k1.LiveViewAutoRefresh
k.DefaultView = k1.DefaultView
k.ScreenDumpDir = k1.ScreenDumpDir
k.RefreshRate = k1.RefreshRate
k.MaxConnRetry = k1.MaxConnRetry

View File

@ -43,3 +43,4 @@ k9s:
memory:
critical: 90
warn: 70
defaultView: ""

View File

@ -43,3 +43,4 @@ k9s:
memory:
critical: 90
warn: 70
defaultView: ""

View File

@ -43,3 +43,4 @@ k9s:
memory:
critical: 90
warn: 70
defaultView: ""

View File

@ -39,3 +39,4 @@ k9s:
memory:
critical: 90
warn: 70
defaultView: ""