feat(ui): Show eks cluster name in the main UI#447
feat(ui): Show eks cluster name in the main UI#447ianis-c wants to merge 3 commits intoawslabs:mainfrom
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.
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.
You're right, would be better to just parse the json config file. I'll do that
There was a problem hiding this comment.
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
}|
|
||
| ctw := text.NewColorTabWriter(&b, 0, 8, 1) | ||
|
|
||
| fmt.Fprintln(&b, "Viewing cluster: ", u.cluster.name) |
There was a problem hiding this comment.
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.
Yes, in my use case it's a pretty important information that's why I put it up.
But I can move it at the 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.