Merge pull request #1270 from RicardoLorenzo/slack_bot_token_authentication

Slack bot token authentication
This commit is contained in:
Stefan Prodan
2022-10-18 17:48:00 +03:00
committed by GitHub
12 changed files with 39 additions and 16 deletions
+9 -1
View File
@@ -133,6 +133,10 @@ func (c *Controller) alert(canary *flaggerv1.Canary, message string, metadata bo
// set hook URL address
url := provider.Spec.Address
// set the token which will be sent in the header
// https://datatracker.ietf.org/doc/html/rfc6750
token := ""
// extract address from secret
if provider.Spec.SecretRef != nil {
secret, err := c.kubeClient.CoreV1().Secrets(providerNamespace).Get(context.TODO(), provider.Spec.SecretRef.Name, metav1.GetOptions{})
@@ -148,6 +152,10 @@ func (c *Controller) alert(canary *flaggerv1.Canary, message string, metadata bo
Errorf("alert provider %s.%s secret does not contain an address", alert.ProviderRef.Name, providerNamespace)
continue
}
if tokenFromSecret, ok := secret.Data["token"]; ok {
token = string(tokenFromSecret)
}
}
// set defaults
@@ -165,7 +173,7 @@ func (c *Controller) alert(canary *flaggerv1.Canary, message string, metadata bo
}
// create notifier based on provider type
f := notifier.NewFactory(url, proxy, username, channel)
f := notifier.NewFactory(url, token, proxy, username, channel)
n, err := f.Notifier(provider.Spec.Type)
if err != nil {
c.logger.With("canary", fmt.Sprintf("%s.%s", canary.Name, canary.Namespace)).