@@ -18,11 +18,10 @@ import (
1818 "fmt"
1919 "log"
2020 "os"
21- "path/filepath"
2221 "reflect"
2322 "testing"
2423
25- patch "github.com/banzaicloud/k8s-objectmatcher/patch"
24+ "github.com/banzaicloud/k8s-objectmatcher/patch"
2625 "github.com/goph/emperror"
2726 "github.com/pkg/errors"
2827 admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1"
@@ -40,13 +39,12 @@ import (
4039 "k8s.io/client-go/dynamic"
4140 "k8s.io/client-go/kubernetes"
4241 "k8s.io/client-go/tools/clientcmd"
43- "k8s.io/client-go/util/homedir"
4442 "k8s.io/klog"
4543)
4644
4745var (
4846 integration = flag .Bool ("integration" , false , "run integration tests" )
49- kubeconfig = flag .String ("kubeconfig" , filepath . Join ( homedir . HomeDir (), ".kube/config" ) , "kubernetes config to use for tests" )
47+ kubeconfig = flag .String ("kubeconfig" , "" , "kubernetes config to use for tests" )
5048 kubecontext = flag .String ("kubecontext" , "" , "kubernetes context to use in tests" )
5149 keepnamespace = flag .Bool ("keepnamespace" , false , "keep the kubernetes namespace that was used for the tests" )
5250 failonerror = flag .Bool ("failonerror" , false , "fail on error to be able to debug invalid state" )
@@ -105,8 +103,12 @@ func (ctx *IntegrationTestContext) CreateNamespace() error {
105103}
106104
107105func (ctx * IntegrationTestContext ) Setup () error {
106+ kubeconfigOverride := os .Getenv ("KUBECONFIG" )
107+ if * kubeconfig != "" {
108+ kubeconfigOverride = * kubeconfig
109+ }
108110 config , err := clientcmd .NewNonInteractiveDeferredLoadingClientConfig (
109- & clientcmd.ClientConfigLoadingRules {ExplicitPath : * kubeconfig },
111+ & clientcmd.ClientConfigLoadingRules {ExplicitPath : kubeconfigOverride },
110112 & clientcmd.ConfigOverrides {CurrentContext : * kubecontext },
111113 ).ClientConfig ()
112114 if err != nil {
0 commit comments