mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-06-25 07:45:01 +00:00
Merge pull request #114 from ksudhir007/fix-kubeconfig
Support KUBECONFIG environment variable.
This commit is contained in:
commit
765feafbcc
@ -10,6 +10,7 @@ import (
|
|||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
"k8s.io/client-go/util/homedir"
|
"k8s.io/client-go/util/homedir"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewFromInCluster(errOut chan error) (*Resolver, error) {
|
func NewFromInCluster(errOut chan error) (*Resolver, error) {
|
||||||
@ -26,8 +27,13 @@ func NewFromInCluster(errOut chan error) (*Resolver, error) {
|
|||||||
|
|
||||||
func NewFromOutOfCluster(kubeConfigPath string, errOut chan error) (*Resolver, error) {
|
func NewFromOutOfCluster(kubeConfigPath string, errOut chan error) (*Resolver, error) {
|
||||||
if kubeConfigPath == "" {
|
if kubeConfigPath == "" {
|
||||||
home := homedir.HomeDir()
|
env := os.Getenv("KUBECONFIG")
|
||||||
kubeConfigPath = filepath.Join(home, ".kube", "config")
|
if env != "" {
|
||||||
|
kubeConfigPath = env
|
||||||
|
} else {
|
||||||
|
home := homedir.HomeDir()
|
||||||
|
kubeConfigPath = filepath.Join(home, ".kube", "config")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
configPathList := filepath.SplitList(kubeConfigPath)
|
configPathList := filepath.SplitList(kubeConfigPath)
|
||||||
|
Loading…
Reference in New Issue
Block a user