-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
57 lines (49 loc) · 1.19 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"
"log"
"log/slog"
"os"
"os/signal"
"syscall"
"github.com/middlewaregruppen/generic-dns-controller/dns"
)
func main() {
opts := slog.HandlerOptions{
Level: slog.LevelDebug,
AddSource: true,
}
handler := slog.NewJSONHandler(os.Stdout, &opts)
slog.SetDefault(slog.New(handler))
//logger := slog.New(handler)
clientset, err := dns.RestK8sClient()
if err != nil {
slog.Error("Error creating a kubernetes client")
return
}
// use switch statement for different DNS providers
switch os.Getenv("DNS_PROVIDER") {
case "ExternalDNS":
//Use ExternalDNS
case "Infoblox":
//Use Infoblox
case "Route53":
//Use Route53
default:
log.Fatalf("Unknown DNS Provider")
}
//initialising DNS Provider
dnsProvider, err := dns.NewInfobloxProvider()
if err != nil {
log.Fatalf("Error initialising Infoblox provider: %v", err)
}
// initialise DNS Controller
controller := dns.NewDNSController(clientset, dnsProvider)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
go controller.Run(ctx)
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
<-sigs
log.Println("Shutting down DNS Controller")
}