This repository has been archived by the owner on Jul 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
main.go
92 lines (71 loc) · 1.76 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package main
import (
"flag"
"sync"
"github.com/k8guard/k8guard-discover/caching"
"github.com/k8guard/k8guard-discover/discover"
"github.com/k8guard/k8guard-discover/messaging"
"github.com/k8guard/k8guard-discover/metrics"
lib "github.com/k8guard/k8guardlibs"
)
var (
Version string
Build string
)
var err error
func init() {
metrics.PromRegister()
caching.InitCache()
}
func main() {
messagingMode := flag.Bool("kmode", false, "messaging mode, no router")
flag.Parse()
if *messagingMode {
defer messaging.CloseBroker()
messaging.InitBroker()
// test if broker is there before making api calls
messaging.TestBrokerWithTestMessage()
var waitGroup sync.WaitGroup
waitGroup.Add(7)
lib.Log.Infof("Starting in message mode using %s as broker", lib.Cfg.MessageBroker)
lib.Log.Info("Version: ", Version)
lib.Log.Info("BuildNumber: ", Build)
if err != nil {
panic(err)
}
go func() {
defer waitGroup.Done()
discover.GetBadNamespaces(discover.GetAllNamespaceFromApi(), true)
}()
go func() {
defer waitGroup.Done()
discover.GetBadDeploys(discover.GetAllDeployFromApi(), true)
}()
go func() {
defer waitGroup.Done()
discover.GetBadDaemonSets(discover.GetAllDaemonSetFromApi(), true)
}()
go func() {
defer waitGroup.Done()
discover.GetBadIngresses(discover.GetAllIngressFromApi(), true)
}()
go func() {
defer waitGroup.Done()
discover.GetBadPods(discover.GetAllPodsFromApi(), true)
}()
go func() {
defer waitGroup.Done()
discover.GetBadJobs(discover.GetAllJobFromApi(), true)
}()
go func() {
defer waitGroup.Done()
discover.GetBadCronJobs(discover.GetAllCronJobFromApi(), true)
}()
waitGroup.Wait()
} else {
go func() {
messaging.InitStatsHandler()
}()
startHttpServer()
}
}