Skip to content

Commit 13cc7d7

Browse files
committed
test fixing kubeconfig path in test logger
1 parent 2ef5ba6 commit 13cc7d7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

test/logger.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import (
2828
"path/filepath"
2929

3030
. "github.com/onsi/gomega"
31+
"k8s.io/client-go/rest"
32+
"k8s.io/client-go/tools/clientcmd"
3133
"k8s.io/klog/v2"
3234
"sigs.k8s.io/cluster-api/test/framework"
3335
ctrl "sigs.k8s.io/controller-runtime"
@@ -102,9 +104,9 @@ func collectManagementClusterLogs(bootstrapClusterProxy *e2e.AzureClusterProxy,
102104

103105
func getKubeConfigPath() string {
104106
config := os.Getenv("KUBECONFIG")
105-
if config == "" {
106-
d, _ := os.UserHomeDir()
107-
return path.Join(d, ".kube", "config")
107+
if _, err := rest.InClusterConfig(); err != nil {
108+
config = clientcmd.NewDefaultClientConfigLoadingRules().GetDefaultFilename()
109+
return config
108110
}
109111

110112
return config

0 commit comments

Comments
 (0)