@@ -3,31 +3,44 @@ package kubernetes
3
3
import (
4
4
"fmt"
5
5
"github.com/humio/humio-operator/api/v1alpha1"
6
+ "sync"
6
7
)
7
8
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
+ )
10
15
11
16
func GetSecretForHa (hn * v1alpha1.HumioAction ) (string , bool ) {
17
+ haSecretsMu .Lock ()
18
+ defer haSecretsMu .Unlock ()
12
19
if secret , found := haSecrets [fmt .Sprintf ("%s %s" , hn .Namespace , hn .Name )]; found {
13
20
return secret , true
14
21
}
15
22
return "" , false
16
23
}
17
24
18
25
func StoreSingleSecretForHa (hn * v1alpha1.HumioAction , token string ) {
26
+ haSecretsMu .Lock ()
27
+ defer haSecretsMu .Unlock ()
19
28
key := fmt .Sprintf ("%s %s" , hn .Namespace , hn .Name )
20
29
haSecrets [key ] = token
21
30
}
22
31
23
32
func GetFullSetOfMergedWebhookheaders (hn * v1alpha1.HumioAction ) (map [string ]string , bool ) {
33
+ haWebhookHeadersMu .Lock ()
34
+ defer haWebhookHeadersMu .Unlock ()
24
35
if secret , found := haWebhookHeaders [fmt .Sprintf ("%s %s" , hn .Namespace , hn .Name )]; found {
25
36
return secret , true
26
37
}
27
38
return nil , false
28
39
}
29
40
30
41
func StoreFullSetOfMergedWebhookActionHeaders (hn * v1alpha1.HumioAction , resolvedSecretHeaders map [string ]string ) {
42
+ haWebhookHeadersMu .Lock ()
43
+ defer haWebhookHeadersMu .Unlock ()
31
44
key := fmt .Sprintf ("%s %s" , hn .Namespace , hn .Name )
32
45
if len (resolvedSecretHeaders ) == 0 {
33
46
haWebhookHeaders [key ] = hn .Spec .WebhookProperties .Headers
0 commit comments