-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
57 lines (46 loc) · 1.16 KB
/
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
48
49
50
51
52
53
54
55
56
57
package main
import (
"context"
"fmt"
"github.com/skhaz/scheduler/controller"
"github.com/skhaz/scheduler/database"
"github.com/skhaz/scheduler/repository"
"github.com/skhaz/scheduler/workflow"
"github.com/spf13/viper"
"go.uber.org/zap"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
ctrl "sigs.k8s.io/controller-runtime"
)
func main() {
viper.AutomaticEnv()
logger, _ := zap.NewDevelopment()
dsn := fmt.Sprintf("host=%v port=%v user=%v password=%v dbname=%v sslmode=disable",
viper.Get("POSTGRES_HOST"),
viper.Get("POSTGRES_PORT"),
viper.Get("POSTGRES_USER"),
viper.Get("POSTGRES_PASSWORD"),
viper.Get("POSTGRES_DB"),
)
db, err := database.Connect(dsn)
if err != nil {
panic(err)
}
registry := repository.NewRepositoryRegistry(
db,
&repository.TriggerRepository{},
)
c := ctrl.GetConfigOrDie()
clientset := kubernetes.NewForConfigOrDie(c)
api, err := dynamic.NewForConfig(c)
if err != nil {
panic(err)
}
var ctx = context.Background()
wf := workflow.NewWorkflow(ctx, api, clientset)
server := controller.InitServer()
server.SetLogger(logger)
server.SetRepositoryRegistry(registry)
server.SetWorkflow(wf)
server.Run()
}