-
Notifications
You must be signed in to change notification settings - Fork 53
/
secrets.go
48 lines (43 loc) · 1.3 KB
/
secrets.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
package v1
import (
storagev1 "github.com/rancher/opni/pkg/apis/storage/v1"
)
func (e *AlertEndpoint) RedactSecrets() {
if slack := e.GetSlack(); slack != nil {
slack.WebhookUrl = storagev1.Redacted
}
if email := e.GetEmail(); email != nil {
redacted := storagev1.Redacted
email.SmtpAuthPassword = &redacted
}
if pg := e.GetPagerDuty(); pg != nil {
pg.IntegrationKey = storagev1.Redacted
}
}
func (a *AlertCondition) RedactSecrets() {}
func (e *AlertEndpoint) UnredactSecrets(unredacted *AlertEndpoint) {
if !e.HasSameImplementation(unredacted) {
return
}
if e.GetSlack() != nil && e.GetSlack().WebhookUrl == storagev1.Redacted {
e.GetSlack().WebhookUrl = unredacted.GetSlack().WebhookUrl
}
if e.GetEmail() != nil && *e.GetEmail().SmtpAuthPassword == storagev1.Redacted {
e.GetEmail().SmtpAuthPassword = unredacted.GetEmail().SmtpAuthPassword
}
if e.GetPagerDuty() != nil && e.GetPagerDuty().IntegrationKey == storagev1.Redacted {
e.GetPagerDuty().IntegrationKey = unredacted.GetPagerDuty().IntegrationKey
}
}
func (e *AlertEndpoint) HasSameImplementation(other *AlertEndpoint) bool {
if e.GetSlack() != nil {
return other.GetSlack() != nil
}
if e.GetEmail() != nil {
return other.GetEmail() != nil
}
if e.GetPagerDuty() != nil {
return other.GetPagerDuty() != nil
}
return false
}