-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
81 lines (62 loc) · 1.31 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
package main
import (
"log"
"net/http"
"os"
"sync"
"time"
"github.com/fatih/color"
)
var (
api = "http://127.0.0.1:8001"
namespace = os.Getenv("NAMESPACE")
vaultClient *VaultClient
yellow = color.New(color.FgYellow).SprintFunc()
green = color.New(color.FgGreen).SprintFunc()
red = color.New(color.FgRed).SprintFunc()
)
func main() {
if namespace == "" {
namespace = "default"
log.Fatal("No NAMESPACE Environment Variable set. Please set the variable and re-run this binary")
}
log.Println(green("Vault2Secrets initialized"))
//okChan := make(chan string)
var wg sync.WaitGroup
go func() {
http.ListenAndServe("0.0.0.0:8888", nil)
}()
done := make(chan struct{})
log.Println(yellow("Waiting ..."))
wg.Add(2)
go func() {
// go get customSecrets
secretEvent := pollSecrets()
for {
select {
case event := <-secretEvent:
// process event
processEvent(event)
case <-done:
wg.Done()
log.Println("Done")
}
}
log.Println("Processing ...")
wg.Done()
log.Println("Done ...")
}()
go func() {
// sync and reconsile
for {
log.Println("Syncing and Checking CustomSecrets")
syncSecrets()
time.Sleep(5 * time.Second)
}
wg.Done()
}()
wg.Wait()
log.Println("Everything Done")
// abc := <-okChan
// fmt.Println(abc)
}