ahmetb / kubectx

Faster way to switch between clusters and namespaces in kubectl
https://kubectx.dev
Apache License 2.0
17.66k stars 1.26k forks source link

Consider open up internal packages #415

Closed PumpkinSeed closed 8 months ago

PumpkinSeed commented 8 months ago

It would be nice to let the internal/kubeconfig to be importable from different projects. This is so far the only package which can work with the kube config so it would be nice to use it from other projects. I ran into the issue, that I need the current context for one of my deployment and actual the deployment is written in Go.

ahmetb commented 8 months ago

I'm not sure this is a good idea because we parse kubeconfig in a very particular way that preserves the YAML structure of the document etc which you probably don't need.

You should probably use https://pkg.go.dev/k8s.io/client-go/tools/clientcmd#NewDefaultClientConfigLoadingRules to load the kubeconfig and read the current-context.

PumpkinSeed commented 8 months ago

Thanks for the answer. Yes, that's kinda make sense, but your implementation is way simpler only to get the context so I thought it worth a try.