-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.go
41 lines (37 loc) · 1.02 KB
/
setup.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
package main
import (
"fmt"
"os"
"github.com/hsson/cluster-monitor/pkg/clusterinfo"
)
func init() {
const clusterConfigKey = "CLUSTER_CONFIG"
clusterConfigLocation := ""
if val, found := os.LookupEnv(clusterConfigKey); found {
clusterConfigLocation = val
}
var err error
// IN_CLUSTER = inside | outside
const clusterKey = "IN_CLUSTER"
if val, found := os.LookupEnv(clusterKey); found {
if val == "inside" {
_clusterClient, err = clusterinfo.NewClientInsideCluster()
} else if val == "outside" {
if clusterConfigLocation != "" {
_clusterClient, err = clusterinfo.NewClientOutsideCluster(clusterinfo.WithConfigLocation(clusterConfigLocation))
} else {
_clusterClient, err = clusterinfo.NewClientOutsideCluster()
}
} else {
fmt.Fprintf(os.Stderr, "Unknown value for $IN_CLUSTER: %s\n", val)
os.Exit(1)
}
} else {
// Default
_clusterClient, err = clusterinfo.NewClientOutsideCluster()
}
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to initialize client: %v", err)
os.Exit(1)
}
}