Skip to content

Commit

Permalink
Bug 1640050 - Check KUBECONFIG env var for Cluster config (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
John Kim authored and Shawn Hurley committed Apr 17, 2019
1 parent 39b53b8 commit cf58dcc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion clients/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"encoding/json"
"errors"
"fmt"
"os"

log "github.com/sirupsen/logrus"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -209,8 +210,12 @@ func newKubernetes() (*KubernetesClient, error) {
// library
clientConfig, err := rest.InClusterConfig()
if err != nil {
config := os.Getenv("KUBECONFIG")
if config == "" {
config = homedir.HomeDir() + "/.kube/config"
}
log.Debug("Checking for a local Cluster Config")
clientConfig, err = createClientConfigFromFile(homedir.HomeDir() + "/.kube/config")
clientConfig, err = createClientConfigFromFile(config)
if err != nil {
log.Error("Failed to create LocalClientSet")
return nil, err
Expand Down

0 comments on commit cf58dcc

Please sign in to comment.