This repository has been archived by the owner on Jul 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
env.go
75 lines (56 loc) · 1.53 KB
/
env.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package tests
import (
"os"
"path/filepath"
"strconv"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
func GetKubeconfig() string {
kubeconfPath := os.Getenv("INTEGRATION_KUBECONFIG")
if kubeconfPath != "" {
return kubeconfPath
}
homeDir, err := os.UserHomeDir()
if err != nil {
Fail("INTEGRATION_KUBECONFIG not provided, failed to use default: " + err.Error())
}
kubeconfPath = filepath.Join(homeDir, ".kube", "config")
_, err = os.Stat(kubeconfPath)
if os.IsNotExist(err) {
return ""
}
Expect(err).NotTo(HaveOccurred())
return kubeconfPath
}
func GetEiriniDockerHubPassword() string {
return lookupOptionalEnv("EIRINIUSER_PASSWORD")
}
func GetEiriniSystemNamespace() string {
return lookupOptionalEnv("EIRINI_SYSTEM_NS")
}
func GetEiriniWorkloadsNamespace() string {
return lookupOptionalEnv("EIRINI_WORKLOADS_NS")
}
func GetEiriniAddress() string {
return lookupOptionalEnv("EIRINI_ADDRESS")
}
func lookupOptionalEnv(key string) string {
value, set := os.LookupEnv(key)
if !set || value == "" {
Skip("Please export optional environment variable " + key + " to run this test")
}
return value
}
func GetTelepresenceServiceName() string {
serviceName := os.Getenv("TELEPRESENCE_SERVICE_NAME")
Expect(serviceName).ToNot(BeEmpty())
return serviceName
}
func GetTelepresencePort() int {
startPort := os.Getenv("TELEPRESENCE_EXPOSE_PORT_START")
Expect(startPort).ToNot(BeEmpty())
portNo, err := strconv.Atoi(startPort)
Expect(err).NotTo(HaveOccurred())
return portNo + GinkgoParallelProcess() - 1
}