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 project ID to the notification, change blue to green for recovery #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
18 changes: 14 additions & 4 deletions function.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Notification struct {
}

type Incident struct {
ProjectID string `json:"scoping_project_id"`
IncidentID string `json:"incident_id"`
ResourceID string `json:"resource_id"`
ResourceName string `json:"resource_name"`
Expand Down Expand Up @@ -70,6 +71,11 @@ func toTeams(notification Notification) MessageCard {
endedDt = time.Unix(et, 0)
}

projectId := notification.Incident.ProjectID
if projectId == "" {
projectId = "-"
}

policyName := notification.Incident.PolicyName
if policyName == "" {
policyName = "-"
Expand All @@ -81,6 +87,10 @@ func toTeams(notification Notification) MessageCard {
}

facts := []Fact{
{
Name: "Project ID",
Value: notification.Incident.ProjectID,
},
{
Name: "Incident ID",
Value: notification.Incident.IncidentID,
Expand All @@ -105,12 +115,12 @@ func toTeams(notification Notification) MessageCard {
}
}

// Blue
colour := "#1890FF"
title := fmt.Sprintf(`Incident closed for "%s".`, policyName)
// Green
colour := "#18FF3B"
title := fmt.Sprintf(`"%s" - Incident closed for "%s".`, projectId, policyName)
if notification.Incident.State == "open" {
// Red
title = fmt.Sprintf(`Incident opened for "%s".`, policyName)
title = fmt.Sprintf(`"%s" - Incident opened for "%s".`, projectId, policyName)
colour = "#F5222D"
}

Expand Down