Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Slack notification support in detector rules #9

Merged
merged 1 commit into from
Jan 31, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions src/terraform-provider-signalform/signalform/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@ func detectorResource() *schema.Resource {
Description: "Seconds since epoch. Used for visualization",
},
"tags": &schema.Schema{
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Description: "Tags associated with the detector",
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Description: "Tags associated with the detector",
},
"teams": &schema.Schema{
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Description: "Team IDs to associate the detector to",
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Description: "Team IDs to associate the detector to",
},
"rule": &schema.Schema{
Type: schema.TypeSet,
Expand Down Expand Up @@ -133,12 +133,12 @@ func detectorResource() *schema.Resource {
Description: "(default: false) When true, notifications and events will not be generated for the detect label",
},
"parameterized_body": &schema.Schema{
Type: schema.TypeString,
Type: schema.TypeString,
Optional: true,
Description: "Custom notification message body when an alert is triggered. See https://developers.signalfx.com/v2/reference#detector-model for more info",
},
"parameterized_subject": &schema.Schema{
Type: schema.TypeString,
Type: schema.TypeString,
Optional: true,
Description: "Custom notification message subject when an alert is triggered. See https://d evelopers.signalfx.com/v2/reference#detector-model for more info",
},
Expand Down Expand Up @@ -205,10 +205,10 @@ func getPayloadDetector(d *schema.ResourceData) ([]byte, error) {

if val, ok := d.GetOk("teams"); ok {
teams := []string{}
for _, team := range val.([]interface{}) {
for _, team := range val.([]interface{}) {
teams = append(teams, team.(string))
}
payload["teams"] = teams
}
payload["teams"] = teams
}

if val, ok := d.GetOk("tags"); ok {
Expand Down Expand Up @@ -262,6 +262,9 @@ func getNotifications(tf_notifications []interface{}) []map[string]interface{} {
item["email"] = vars[1]
} else if vars[0] == "PagerDuty" {
item["credentialId"] = vars[1]
} else if vars[0] == "Slack" {
item["credentialId"] = vars[1]
item["channel"] = vars[2]
} else if vars[0] == "Webhook" {
item["secret"] = vars[1]
item["url"] = vars[2]
Expand Down