-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Use current k9s NS if new context has no default NS #2197
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mikutas Thank you for your PR. I think this issue was brought up before and we'd settled on using the namespace associated with the new context.
@@ -403,10 +403,7 @@ func (a *App) switchContext(name string) error { | |||
a.Halt() | |||
defer a.Resume() | |||
{ | |||
ns, err := a.Conn().Config().CurrentNamespaceName() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the current behavior is correct i.e when switching context we want to use the default namespace associated with that context vs using the namespace in the k9s config. For example if ctx1
specifies default namespace ns1
but the k9s config (if it exists!) specifies ns2
then k9s should use ns1
as the default namespace. This proposal would always override the namespace with the k9s config namespace or default
if not set.
That said, a case could be made if the new context does not specify a namespace where we could override with the last visited namespace from the k9s config if set....
Does this make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I think I got the intent of existing behavior. 💡
I missed the usecase that we specify ns expressly in kubeconfig.
On the other hand, I'm not in the habit of specifying ns in kubeconfig, so the fallback suggested will be very convenient for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, long time no see @derailed .
Is there something I can do to go ahead?
b684a0b
to
74bb63a
Compare
and set k9s's active ns if no ns specified in the context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mikutas Thanks for this update!
* 'master' of github.com:derailed/k9s: (130 commits) added flux suspended resources retrieval plugin (derailed#1584) Provide white blur so images work in dark modes (derailed#1597) Add context to get-all (derailed#1701) fix brew command in the readme (derailed#2012) Add support for using custom kubeconfig with log_full plugin (derailed#2014) feat: allow for multiple plugin files in $XDG_DATA_DIRS/k9s/plugins (derailed#2029) Clean up issues introduced by derailed#2125 (derailed#2289) Pod view resembles more the output of kubectl get pods -o wide (derailed#2125) Update README.md with snap install (derailed#2262) Add snapcraft config (derailed#2123) storageclasses view keeps the same output as kubectl get sc (derailed#2132) Fix merge issues with PR derailed#2168 (derailed#2288) Add colour config for container picker (derailed#2140) Add env var to disable node pod counts (derailed#2168) Use current k9s NS if new context has no default NS (derailed#2197) Bump actions/setup-go from 4.0.1 to 4.1.0 (derailed#2200) fix: trigger a single log refresh after changing 'since' (derailed#2202) Add crossplane plugin (derailed#2204) fix(derailed#1359): add option to keep missing clusters in config (derailed#2213) K9s release v0.28.2 ...
* Fix resetting active namespace when switching ctx * Respect existing behavior and set k9s's active ns if no ns specified in the context
* Fix resetting active namespace when switching ctx * Respect existing behavior and set k9s's active ns if no ns specified in the context
closes #1461
Switching context causes resetting active namespace for now and as a result
default
NS is always activated.