-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.go
35 lines (30 loc) · 964 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
package main
import (
"log"
"os"
"github.com/RoadieHQ/kubewise/controller"
"github.com/RoadieHQ/kubewise/handlers"
"github.com/RoadieHQ/kubewise/handlers/googlechat"
"github.com/RoadieHQ/kubewise/handlers/slack"
"github.com/RoadieHQ/kubewise/handlers/webhook"
"github.com/RoadieHQ/kubewise/kwrelease"
)
func main() {
if _, ok := os.LookupEnv("KW_HANDLER"); !ok {
log.Fatalln("KW_HANDLER environment variable is required.")
}
var eventHandler handlers.Handler
switch os.Getenv("KW_HANDLER") {
case "googlechat":
eventHandler = new(googlechat.GoogleChat)
case "webhook":
eventHandler = new(webhook.Webhook)
// Slack is the default for backwards compatibility reasons. It was the first handler.
default:
eventHandler = new(slack.Slack)
}
eventHandler.Init()
eventHandler.HandleServerStartup(kwrelease.ListActiveReleases())
// This is a blocking call. Code placed after this won't run until teardown.
controller.Start(eventHandler)
}