Fix kubeconfig default working correctly

Kuberentes e2e framework get kubeconfig information from
KUBECONFIG environment variable. set the variable by default.
This commit is contained in:
Woohyung Han 2019-12-01 12:18:05 +09:00 committed by mergify[bot]
parent 671e2d814a
commit 63589f3314

View File

@ -4,6 +4,8 @@ import (
"flag" "flag"
"fmt" "fmt"
"log" "log"
"os"
"path/filepath"
"testing" "testing"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
@ -24,6 +26,9 @@ func init() {
flag.BoolVar(&rookRequired, "deploy-rook", true, "deploy rook on kubernetes") flag.BoolVar(&rookRequired, "deploy-rook", true, "deploy rook on kubernetes")
flag.IntVar(&deployTimeout, "deploy-timeout", 10, "timeout to wait for created kubernetes resources") flag.IntVar(&deployTimeout, "deploy-timeout", 10, "timeout to wait for created kubernetes resources")
setDefaultKubeconfig()
// Register framework flags, then handle flags // Register framework flags, then handle flags
framework.HandleFlags() framework.HandleFlags()
framework.AfterReadingAllFlags(&framework.TestContext) framework.AfterReadingAllFlags(&framework.TestContext)
@ -32,6 +37,14 @@ func init() {
fmt.Println("timeout for deploytimeout ", deployTimeout) fmt.Println("timeout for deploytimeout ", deployTimeout)
} }
func setDefaultKubeconfig() {
_, exists := os.LookupEnv("KUBECONFIG")
if !exists {
defaultKubeconfig := filepath.Join(os.Getenv("HOME"), ".kube", "config")
os.Setenv("KUBECONFIG", defaultKubeconfig)
}
}
// removeCephCSIResource is a temporary fix for CI to remove the ceph-csi resources deployed by rook // removeCephCSIResource is a temporary fix for CI to remove the ceph-csi resources deployed by rook
func removeCephCSIResource() { func removeCephCSIResource() {
// cleanup rbd and cephfs deamonset deployed by rook // cleanup rbd and cephfs deamonset deployed by rook