-
Notifications
You must be signed in to change notification settings - Fork 1
/
grasla.go
32 lines (29 loc) · 912 Bytes
/
grasla.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
package main
import (
"log"
"os"
"github.com/LifeMemoryTeam/slack-grafana-image-renderer-picker/pkg/config"
"github.com/LifeMemoryTeam/slack-grafana-image-renderer-picker/pkg/grafana"
"github.com/LifeMemoryTeam/slack-grafana-image-renderer-picker/pkg/slack"
)
func main() {
log.Println(os.Getenv("CONFIG_FILE"))
if err := config.Load(os.Getenv("CONFIG_FILE")); err != nil {
log.Println(err.Error())
panic(err)
}
g := grafana.NewClient(config.Global.Grafana.Endpoint)
if config.Global.Grafana.UseClientAuth {
if err := g.LoadP12(config.Global.Grafana.ClientAuthP12, os.Getenv("CLIENT_AUTH_PASSWORD")); err != nil {
panic(err)
}
}
apiKey := os.Getenv("GRAFANA_API_KEY")
if apiKey != "" {
g.SetAPIKey(apiKey)
}
server := slack.NewSlackServer(g, config.Global.Slack.Token, config.Global.Slack.Secret, config.Global.Slack.Addr)
if err := server.Start(); err != nil {
panic(err)
}
}