put property name back as originator and recipients

This commit is contained in:
cemturker 2020-11-25 00:30:23 +01:00
parent c5e2b0f159
commit 199f14667e
4 changed files with 22 additions and 22 deletions

View File

@ -129,8 +129,8 @@ Note that you can also add environment variables in the configuration file (i.e.
| `alerting.mattermost.insecure` | Whether to skip verifying the server's certificate chain and host name | `false` |
| `alerting.messagebird` | Settings for alerts of type `messagebird` | `{}` |
| `alerting.messagebird.access-key` | Messagebird access key | Required `""` |
| `alerting.messagebird.from` | The sender of the message | Required `""` |
| `alerting.messagebird.to` | The recipients of the message | Required `""` |
| `alerting.messagebird.originator` | The sender of the message | Required `""` |
| `alerting.messagebird.recipients` | The recipients of the message | Required `""` |
| `alerting.custom` | Configuration for custom actions on failure or alerts | `{}` |
| `alerting.custom.url` | Custom alerting request url | Required `""` |
| `alerting.custom.method` | Request method | `GET` |
@ -319,8 +319,8 @@ Example of sending **sms** message alert by using Messagebird
alerting:
messagebird:
access-key: "..."
from: "31619191918"
to: "31619191919,31619191920"
originator: "31619191918"
recipients: "31619191919,31619191920"
services:
- name: twinnation
interval: 30s

View File

@ -14,14 +14,14 @@ const (
// AlertProvider is the configuration necessary for sending an alert using Messagebird
type AlertProvider struct {
AccessKey string `yaml:"access-key"`
From string `yaml:"from"`
To string `yaml:"to"`
AccessKey string `yaml:"access-key"`
Originator string `yaml:"originator"`
Recipients string `yaml:"recipients"`
}
// IsValid returns whether the provider's configuration is valid
func (provider *AlertProvider) IsValid() bool {
return len(provider.AccessKey) > 0 && len(provider.From) > 0 && len(provider.To) > 0
return len(provider.AccessKey) > 0 && len(provider.Originator) > 0 && len(provider.Recipients) > 0
}
// ToCustomAlertProvider converts the provider into a custom.AlertProvider
@ -41,7 +41,7 @@ func (provider *AlertProvider) ToCustomAlertProvider(service *core.Service, aler
"originator": "%s",
"recipients": "%s",
"body": "%s"
}`, provider.From, provider.To, message),
}`, provider.Originator, provider.Recipients, message),
Headers: map[string]string{
"Content-Type": "application/json",
"Authorization": fmt.Sprintf("AccessKey %s", provider.AccessKey),

View File

@ -13,9 +13,9 @@ func TestMessagebirdAlertProvider_IsValid(t *testing.T) {
t.Error("provider shouldn't have been valid")
}
validProvider := AlertProvider{
AccessKey: "1",
From: "1",
To: "1",
AccessKey: "1",
Originator: "1",
Recipients: "1",
}
if !validProvider.IsValid() {
t.Error("provider should've been valid")
@ -24,9 +24,9 @@ func TestMessagebirdAlertProvider_IsValid(t *testing.T) {
func TestAlertProvider_ToCustomAlertProviderWithResolvedAlert(t *testing.T) {
provider := AlertProvider{
AccessKey: "1",
From: "1",
To: "1",
AccessKey: "1",
Originator: "1",
Recipients: "1",
}
customAlertProvider := provider.ToCustomAlertProvider(&core.Service{}, &core.Alert{}, &core.Result{}, true)
if customAlertProvider == nil {
@ -39,9 +39,9 @@ func TestAlertProvider_ToCustomAlertProviderWithResolvedAlert(t *testing.T) {
func TestAlertProvider_ToCustomAlertProviderWithTriggeredAlert(t *testing.T) {
provider := AlertProvider{
AccessKey: "1",
From: "1",
To: "1",
AccessKey: "1",
Originator: "1",
Recipients: "1",
}
customAlertProvider := provider.ToCustomAlertProvider(&core.Service{}, &core.Alert{}, &core.Result{}, false)
if customAlertProvider == nil {

View File

@ -416,11 +416,11 @@ services:
if config.Alerting.Messagebird.AccessKey != "1" {
t.Errorf("Messagebird access key should've been %s, but was %s", "1", config.Alerting.Messagebird.AccessKey)
}
if config.Alerting.Messagebird.From != "31619191918" {
t.Errorf("Messagebird from field should've been %s, but was %s", "31619191918", config.Alerting.Messagebird.From)
if config.Alerting.Messagebird.Originator != "31619191918" {
t.Errorf("Messagebird originator field should've been %s, but was %s", "31619191918", config.Alerting.Messagebird.Originator)
}
if config.Alerting.Messagebird.To != "31619191919" {
t.Errorf("Messagebird to field should've been %s, but was %s", "31619191919", config.Alerting.Messagebird.To)
if config.Alerting.Messagebird.Recipients != "31619191919" {
t.Errorf("Messagebird to recipients should've been %s, but was %s", "31619191919", config.Alerting.Messagebird.Recipients)
}
if len(config.Services) != 1 {
t.Error("There should've been 1 service")