diff --git a/signalfx/notifications.go b/signalfx/notifications.go index 017e6ab8..e16e1470 100644 --- a/signalfx/notifications.go +++ b/signalfx/notifications.go @@ -9,24 +9,28 @@ import ( ) const ( - BigPandaNotificationType string = "BigPanda" - EmailNotificationType string = "Email" - JiraNotificationType string = "Jira" - Office365NotificationType string = "Office365" - OpsgenieNotificationType string = "Opsgenie" - PagerDutyNotificationType string = "PagerDuty" - ServiceNowNotificationType string = "ServiceNow" - SlackNotificationType string = "Slack" - TeamNotificationType string = "Team" - TeamEmailNotificationType string = "TeamEmail" - VictorOpsNotificationType string = "VictorOps" - WebhookNotificationType string = "Webhook" - XMattersNotificationType string = "XMatters" + AmazonEventBrigeNotificationType string = "AmazonEventBridge" + BigPandaNotificationType string = "BigPanda" + EmailNotificationType string = "Email" + JiraNotificationType string = "Jira" + Office365NotificationType string = "Office365" + OpsgenieNotificationType string = "Opsgenie" + PagerDutyNotificationType string = "PagerDuty" + ServiceNowNotificationType string = "ServiceNow" + SlackNotificationType string = "Slack" + TeamNotificationType string = "Team" + TeamEmailNotificationType string = "TeamEmail" + VictorOpsNotificationType string = "VictorOps" + WebhookNotificationType string = "Webhook" + XMattersNotificationType string = "XMatters" ) func getNotifyStringFromAPI(not *notification.Notification) (string, error) { nt := not.Type switch nt { + case AmazonEventBrigeNotificationType: + aeb := not.Value.(*notification.AmazonEventBrigeNotification) + return fmt.Sprintf("%s,%s", nt, aeb.CredentialId), nil case BigPandaNotificationType: bp := not.Value.(*notification.BigPandaNotification) return fmt.Sprintf("%s,%s", nt, bp.CredentialId), nil @@ -79,6 +83,11 @@ func getNotifications(tfNotifications []interface{}) ([]*notification.Notificati var n interface{} switch vars[0] { + case AmazonEventBrigeNotificationType: + n = ¬ification.AmazonEventBrigeNotification{ + Type: vars[0], + CredentialId: vars[1], + } case BigPandaNotificationType: n = ¬ification.BigPandaNotification{ Type: vars[0], @@ -175,7 +184,7 @@ func validateNotification(val interface{}, key string) (warns []string, errs []e } switch parts[0] { - case BigPandaNotificationType, JiraNotificationType, Office365NotificationType, ServiceNowNotificationType, PagerDutyNotificationType, TeamNotificationType, TeamEmailNotificationType, XMattersNotificationType: + case AmazonEventBrigeNotificationType, BigPandaNotificationType, JiraNotificationType, Office365NotificationType, ServiceNowNotificationType, PagerDutyNotificationType, TeamNotificationType, TeamEmailNotificationType, XMattersNotificationType: // These are ok, but have no further validation case EmailNotificationType: if !strings.Contains(parts[1], "@") { diff --git a/signalfx/notifications_test.go b/signalfx/notifications_test.go index eb8ca96a..60f004a1 100644 --- a/signalfx/notifications_test.go +++ b/signalfx/notifications_test.go @@ -113,6 +113,13 @@ func TestNotifyStringFromAPI(t *testing.T) { CredentialId: "XXX", }, }, + ¬ification.Notification{ + Type: AmazonEventBrigeNotificationType, + Value: ¬ification.AmazonEventBrigeNotification{ + Type: AmazonEventBrigeNotificationType, + CredentialId: "XXX", + }, + }, } expected := []string{ @@ -130,6 +137,7 @@ func TestNotifyStringFromAPI(t *testing.T) { "ServiceNow,XXX", "VictorOps,XXX,YYY", "XMatters,XXX", + "AmazonEventBridge,XXX", } for i, v := range values { @@ -163,6 +171,7 @@ func TestNotifyValidationBad(t *testing.T) { "ServiceNow", "VictorOps,XXX", "XMatters", + "AmazonEventBridge", } for _, v := range busted { @@ -186,6 +195,7 @@ func TestGetNotifications(t *testing.T) { "ServiceNow,credId", "VictorOps,credId,routingKey", "XMatters,credId", + "AmazonEventBridge,credId", } expected := []*notification.Notification{ @@ -287,6 +297,13 @@ func TestGetNotifications(t *testing.T) { CredentialId: "credId", }, }, + ¬ification.Notification{ + Type: AmazonEventBrigeNotificationType, + Value: ¬ification.AmazonEventBrigeNotification{ + Type: AmazonEventBrigeNotificationType, + CredentialId: "credId", + }, + }, } nots, err := getNotifications(values) assert.NoError(t, err, "No error expected on notification conversion")