-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmain.go
39 lines (34 loc) · 993 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
package main
import (
"github.com/keptn-service-template-go/handler"
"github.com/keptn/go-utils/pkg/sdk"
"github.com/sirupsen/logrus"
"log"
"os"
)
const getSliTriggeredEvent = "sh.keptn.event.get-sli.triggered"
const actionTriggeredEvent = "sh.keptn.event.action.triggered"
const serviceName = "keptn-service-template-go"
const envVarLogLevel = "LOG_LEVEL"
func main() {
if os.Getenv(envVarLogLevel) != "" {
logLevel, err := logrus.ParseLevel(os.Getenv(envVarLogLevel))
if err != nil {
logrus.WithError(err).Error("could not parse log level provided by 'LOG_LEVEL' env var")
logrus.SetLevel(logrus.InfoLevel)
} else {
logrus.SetLevel(logLevel)
}
}
log.Printf("Starting %s", serviceName)
log.Fatal(sdk.NewKeptn(
serviceName,
sdk.WithTaskHandler(
actionTriggeredEvent,
handler.NewActionTriggeredEventHandler()),
sdk.WithTaskHandler(
getSliTriggeredEvent,
handler.NewGetSliEventHandler()),
sdk.WithLogger(logrus.StandardLogger()),
).Start())
}