@@ -3,31 +3,44 @@ package kubernetes
33import (
44 "fmt"
55 "github.com/humio/humio-operator/api/v1alpha1"
6+ "sync"
67)
78
8- var haSecrets map [string ]string = make (map [string ]string )
9- var haWebhookHeaders map [string ]map [string ]string = make (map [string ]map [string ]string )
9+ var (
10+ haSecrets = make (map [string ]string )
11+ haSecretsMu sync.Mutex
12+ haWebhookHeaders = make (map [string ]map [string ]string )
13+ haWebhookHeadersMu sync.Mutex
14+ )
1015
1116func GetSecretForHa (hn * v1alpha1.HumioAction ) (string , bool ) {
17+ haSecretsMu .Lock ()
18+ defer haSecretsMu .Unlock ()
1219 if secret , found := haSecrets [fmt .Sprintf ("%s %s" , hn .Namespace , hn .Name )]; found {
1320 return secret , true
1421 }
1522 return "" , false
1623}
1724
1825func StoreSingleSecretForHa (hn * v1alpha1.HumioAction , token string ) {
26+ haSecretsMu .Lock ()
27+ defer haSecretsMu .Unlock ()
1928 key := fmt .Sprintf ("%s %s" , hn .Namespace , hn .Name )
2029 haSecrets [key ] = token
2130}
2231
2332func GetFullSetOfMergedWebhookheaders (hn * v1alpha1.HumioAction ) (map [string ]string , bool ) {
33+ haWebhookHeadersMu .Lock ()
34+ defer haWebhookHeadersMu .Unlock ()
2435 if secret , found := haWebhookHeaders [fmt .Sprintf ("%s %s" , hn .Namespace , hn .Name )]; found {
2536 return secret , true
2637 }
2738 return nil , false
2839}
2940
3041func StoreFullSetOfMergedWebhookActionHeaders (hn * v1alpha1.HumioAction , resolvedSecretHeaders map [string ]string ) {
42+ haWebhookHeadersMu .Lock ()
43+ defer haWebhookHeadersMu .Unlock ()
3144 key := fmt .Sprintf ("%s %s" , hn .Namespace , hn .Name )
3245 if len (resolvedSecretHeaders ) == 0 {
3346 haWebhookHeaders [key ] = hn .Spec .WebhookProperties .Headers
0 commit comments