-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.go
39 lines (30 loc) · 856 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 (
"context"
"flag"
"github.com/stolostron/search-v2-api/pkg/config"
"github.com/stolostron/search-v2-api/pkg/database"
"github.com/stolostron/search-v2-api/pkg/rbac"
"github.com/stolostron/search-v2-api/pkg/server"
klog "k8s.io/klog/v2"
)
func main() {
// Initialize the logger.
klog.InitFlags(nil)
flag.Parse()
defer klog.Flush()
klog.Info("Starting search-v2-api.")
// Read the config from the environment.
config.Cfg.PrintConfig()
// Validate required configuration to proceed.
configError := config.Cfg.Validate()
if configError != nil {
klog.Fatal(configError)
}
ctx := context.Background()
// Establish the database connection.
database.GetConnPool(ctx)
// Start process to watch the RBAC config andd update the cache.
go rbac.GetCache().StartBackgroundValidation(ctx)
server.StartAndListen()
}