-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
56 lines (46 loc) · 1.04 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
package main
import (
"github.com/spf13/cobra"
)
func main() {
startCmd := &cobra.Command{
Use: "start",
Short: "Start Ingress-dns in non-daemon mode",
Run: func(cmd *cobra.Command, args []string) {
start(args)
},
}
rootCmd := &cobra.Command{
Use: "ingress-dns",
}
rootCmd.AddCommand(startCmd)
rootCmd.Execute()
}
func start(args []string) {
loadConfig()
SendToConsul(getBindings())
blockForever()
}
func blockForever() {
select {}
}
func getBindings() []Binding {
bindings := make([]Binding, len(appConfig.UserConfigs))
counter := 0
serviceMap := GetServices().GetServiceMap()
for _, config := range appConfig.UserConfigs {
if service, present := serviceMap[config.ControllerService]; present {
bindings[counter] = Binding{config, service, Ingress{}}
counter += 1
}
}
bindings = bindings[:counter]
for _, ingress := range GetIngresses().Items {
for i, config := range bindings {
if ingress.Metadata.ContainsAnnotations(config.Annotation) {
bindings[i].Ingress = ingress
}
}
}
return bindings
}