Skip to content

Commit ec7c9ce

Browse files
committed
Update kubeconfig handling
Signed-off-by: Tomáš Smädo <[email protected]>
1 parent 3731237 commit ec7c9ce

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Tests/kaas/kaas-sonobuoy-tests/scs_k8s_conformance_tests/scs_0212_v1_registry_standard_test.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ import (
44
"context"
55
"fmt"
66
"log"
7+
"os"
78
"testing"
89

10+
"path/filepath"
11+
912
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1013
"k8s.io/client-go/kubernetes"
11-
"k8s.io/client-go/rest"
14+
"k8s.io/client-go/tools/clientcmd"
1215
)
1316

1417
// list of common Harbor components.
@@ -23,7 +26,8 @@ var HarborComponentNames = []string{
2326

2427
func Test_scs_0212_registry_standard_test(t *testing.T) {
2528
// Set up the Kubernetes client
26-
config, err := rest.InClusterConfig()
29+
// config, err := rest.InClusterConfig()
30+
config, err := clientcmd.BuildConfigFromFlags("", filepath.Join(homeDir(), ".kube", "config"))
2731
if err != nil {
2832
log.Fatalf("Failed to create rest config: %v", err)
2933
}
@@ -84,3 +88,10 @@ func checkServices(clientset *kubernetes.Clientset) error {
8488
func containsString(str, substr string) bool {
8589
return len(str) > 0 && len(substr) > 0 && (str == substr || (len(str) > len(substr) && str[:len(substr)] == substr))
8690
}
91+
92+
func homeDir() string {
93+
if h := os.Getenv("HOME"); h != "" {
94+
return h
95+
}
96+
return ""
97+
}

0 commit comments

Comments
 (0)