cmd/common: Honor KUBECONFIG environment variable
If set, use it.  Prep for adding tests which expect it.
package common
import (
+ "os"
+
"github.com/golang/glog"
configclientset "github.com/openshift/client-go/config/clientset/versioned"
cvoclientset "github.com/openshift/cluster-version-operator/pkg/generated/clientset/versioned"
@@ -50,6 +52,10 @@ func NewClientBuilder(kubeconfig string) (*ClientBuilder, error) {
var config *rest.Config
var err error
+ if kubeconfig == "" {
+ kubeconfig = os.Getenv("KUBECONFIG")
+ }
+
if kubeconfig != "" {
glog.V(4).Infof("Loading kube client config from path %q", kubeconfig)
config, err = clientcmd.BuildConfigFromFlags("", kubeconfig)
