-
Notifications
You must be signed in to change notification settings - Fork 139
feat(ui): Show eks cluster name in the main UI #447
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
base: main
Are you sure you want to change the base?
Conversation
Hi @tzneal, do you think this feature could be integrated ? |
kubeconfig = "~/.kube/config" | ||
} | ||
|
||
out, err := exec.Command("kubectl", "config", "current-context", "--kubeconfig", kubeconfig).Output() |
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.
It should be possible to pull this from the kubeconfig file, I would greatly prefer that to running the kubectl binary.
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.
You're right, would be better to just parse the json config file. I'll do that
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 you can get it via something like this:
-func getConfig(kubeconfig, context string) (*rest.Config, error) {
- // use the current context in kubeconfig
- return clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
+func getConfig(kubeconfig, context string) (string, *rest.Config, error) {
+ loadCfg := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
&clientcmd.ClientConfigLoadingRules{Precedence: strings.Split(kubeconfig, ":")},
- &clientcmd.ConfigOverrides{CurrentContext: context}).ClientConfig()
+ &clientcmd.ConfigOverrides{CurrentContext: context})
+ raw, err := loadCfg.RawConfig()
+ if err != nil {
+ return "", nil, err
+ }
+ cfg, err := loadCfg.ClientConfig()
+ if err != nil {
+ return "", nil, err
+ }
+ return raw.CurrentContext, cfg, err
}
@@ -88,6 +88,10 @@ func (u *UIModel) View() string { | |||
}) | |||
|
|||
ctw := text.NewColorTabWriter(&b, 0, 8, 1) | |||
|
|||
fmt.Fprintln(&b, "Viewing cluster: ", u.cluster.name) |
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 taking up a new line on the screen is too much, can it be fit anywhere else? Maybe after the "q: quit" message?
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.
Yes, in my use case it's a pretty important information thanks why I put it up but I can move it bottom under the controls description.
Issue #, if available:
No linked issue.
Description of changes:
This feature retrieve and show the current EKS cluster being shown in the eks-node-viewer main UI.
It can be useful when working with more than one cluster (one or more clusters per environment for example).
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.