Skip to content

Commit

Permalink
Merge pull request #8 from bcourtel/read-kubeconfig-from-env
Browse files Browse the repository at this point in the history
fix: read $KUBECONFIG from env if it exists
  • Loading branch information
clbx authored Feb 1, 2024
2 parents 13eb92c + e2869ed commit e24ac7e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion util.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ func buildPvcbGetJob(namespace string, image string, pvc corev1.PersistentVolume
func getClientSetFromKubeconfig() (*kubernetes.Clientset, *rest.Config) {
var kubeconfig string

if home := homedir.HomeDir(); home != "" {
if configFromEnv := os.Getenv("KUBECONFIG"); configFromEnv != "" {
kubeconfig = configFromEnv
} else if home := homedir.HomeDir(); home != "" {
kubeconfig = filepath.Join(home, ".kube", "config")
} else {
fmt.Println("error: unable to locate kubeconfig")
Expand Down

0 comments on commit e24ac7e

Please sign in to comment.