/
config.go
55 lines (45 loc) · 1.14 KB
/
config.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
package common
import (
"os"
"strings"
"knative.dev/func/pkg/k8s"
)
// Intended to provide setup configuration for E2E tests
const (
DefaultRegistry = "localhost:50000/user"
)
var testRegistry = ""
func init() {
// Setup test Registry.
testRegistry = os.Getenv("E2E_REGISTRY_URL")
if testRegistry == "" || testRegistry == "default" {
if k8s.IsOpenShift() {
testRegistry = k8s.GetDefaultOpenShiftRegistry()
} else {
testRegistry = DefaultRegistry
}
}
}
// GetRegistry returns registry
func GetRegistry() string {
return testRegistry
}
// GetFuncBinaryPath should return the Path of 'func' binary under test
func GetFuncBinaryPath() string {
return GetOsEnvOrDefault("E2E_FUNC_BIN_PATH", "")
}
// GetRuntime returns the runtime that should be tested.
func GetRuntime() string {
return GetOsEnvOrDefault("E2E_RUNTIME", "node")
}
// IsUseKnFunc indicates that tests should be run against "kn func" instead of "func" binary
func IsUseKnFunc() bool {
return strings.EqualFold(os.Getenv("E2E_USE_KN_FUNC"), "true")
}
func GetOsEnvOrDefault(env string, dflt string) string {
e := os.Getenv(env)
if e == "" {
return dflt
}
return e
}