-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
47 lines (36 loc) · 973 Bytes
/
main.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
package main
import (
"log"
"os"
"github.com/tsuru/tsuru-prometheus-api/api"
"github.com/tsuru/tsuru-prometheus-api/service"
)
func main() {
kubernetesToken := os.Getenv("KUBERNETES_TOKEN")
tsuruTarget := os.Getenv("TSURU_TARGET")
tsuruToken := os.Getenv("TSURU_TOKEN")
authUser := os.Getenv("AUTH_USER")
if authUser == "" {
authUser = "admin"
}
authPassword := os.Getenv("AUTH_PASSWORD")
if authPassword == "" {
authPassword = "admin"
}
if tsuruTarget == "" || tsuruToken == "" {
log.Fatalln("TSURU_TARGET and TSURU_TOKEN must be set")
}
var clientGetter service.K8SClientGetter
if kubernetesToken == "" {
clientGetter = service.NewK8SClientGetterWithKubeConfig
} else {
clientGetter = service.NewK8SClientGetterWithToken(kubernetesToken)
}
svc := service.NewService(tsuruToken, clientGetter)
server := api.NewServer(api.ServerOpts{
Service: svc,
AuthUser: authUser,
AuthPassword: authPassword,
})
server.Run()
}