mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-06-22 06:18:51 +00:00
Support KUBECONFIG environment variable.
If KUBECONFIG environment variable is set, use it. Otherwise default to ~/.kube/config
This commit is contained in:
parent
6e279bfca5
commit
cef0e01cf6
@ -10,6 +10,7 @@ import (
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
"k8s.io/client-go/util/homedir"
|
||||
"path/filepath"
|
||||
"os"
|
||||
)
|
||||
|
||||
func NewFromInCluster(errOut chan error) (*Resolver, error) {
|
||||
@ -26,9 +27,14 @@ func NewFromInCluster(errOut chan error) (*Resolver, error) {
|
||||
|
||||
func NewFromOutOfCluster(kubeConfigPath string, errOut chan error) (*Resolver, error) {
|
||||
if kubeConfigPath == "" {
|
||||
env := os.Getenv("KUBECONFIG")
|
||||
if env != "" {
|
||||
kubeConfigPath = env
|
||||
} else {
|
||||
home := homedir.HomeDir()
|
||||
kubeConfigPath = filepath.Join(home, ".kube", "config")
|
||||
}
|
||||
}
|
||||
|
||||
configPathList := filepath.SplitList(kubeConfigPath)
|
||||
configLoadingRules := &clientcmd.ClientConfigLoadingRules{}
|
||||
|
Loading…
Reference in New Issue
Block a user