Skip to content
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

Feature/initial view #2866

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,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
Expand Down
4 changes: 4 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ func run(cmd *cobra.Command, args []string) error {
log.Error().Err(err).Msgf("Fail to load global/context configuration")
}
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
}
Expand Down
1 change: 1 addition & 0 deletions internal/config/json/schemas/k9s.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"noExitOnCtrlC": { "type": "boolean" },
"skipLatestRevCheck": { "type": "boolean" },
"disablePodCounting": { "type": "boolean" },
"defaultView": { "type": "string" },
"ui": {
"type": "object",
"additionalProperties": false,
Expand Down
2 changes: 2 additions & 0 deletions internal/config/k9s.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,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
manualHeadless *bool
manualLogoless *bool
Expand Down Expand Up @@ -96,6 +97,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
Expand Down
1 change: 1 addition & 0 deletions internal/config/testdata/configs/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ k9s:
memory:
critical: 90
warn: 70
defaultView: ""
1 change: 1 addition & 0 deletions internal/config/testdata/configs/expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ k9s:
memory:
critical: 90
warn: 70
defaultView: ""
1 change: 1 addition & 0 deletions internal/config/testdata/configs/k9s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ k9s:
memory:
critical: 90
warn: 70
defaultView: ""
1 change: 1 addition & 0 deletions internal/config/testdata/configs/k9s_toast.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ k9s:
memory:
critical: 90
warn: 70
defaultView: ""
Loading