Просмотр исходного кода

rename application -> job in relevant alerts

Alexander Belanger 3 лет назад
Родитель
Сommit
463e5717ec

+ 8 - 1
internal/notifier/sendgrid/incident_notifier.go

@@ -2,6 +2,7 @@ package sendgrid
 
 import (
 	"fmt"
+	"strings"
 
 	"github.com/porter-dev/porter/api/types"
 	"github.com/porter-dev/porter/internal/models"
@@ -31,10 +32,16 @@ func (s *IncidentNotifier) NotifyNew(incident *types.Incident, url string) error
 
 	personalizations := make([]*mail.Personalization, 0)
 
+	resourceKind := "application"
+
+	if strings.ToLower(string(incident.InvolvedObjectKind)) == "job" {
+		resourceKind = "job"
+	}
+
 	templData := map[string]interface{}{
 		"incident_text": incident.Summary,
 		"app_url":       url,
-		"subject":       fmt.Sprintf("Your application %s crashed on Porter", incident.ReleaseName),
+		"subject":       fmt.Sprintf("Your %s %s crashed on Porter", resourceKind, incident.ReleaseName),
 		"preheader":     incident.Summary,
 		"created_at":    fmt.Sprintf("%s", incident.CreatedAt.Format("Jan 2, 2006 at 3:04pm (MST)")),
 	}

+ 9 - 1
internal/notifier/slack/incident_notifier.go

@@ -5,6 +5,7 @@ import (
 	"encoding/json"
 	"fmt"
 	"net/http"
+	"strings"
 	"time"
 
 	"github.com/porter-dev/porter/api/types"
@@ -24,8 +25,15 @@ func NewIncidentNotifier(slackInts ...*integrations.SlackIntegration) *IncidentN
 func (s *IncidentNotifier) NotifyNew(incident *types.Incident, url string) error {
 	res := []*SlackBlock{}
 
+	resourceKind := "application"
+
+	if strings.ToLower(string(incident.InvolvedObjectKind)) == "job" {
+		resourceKind = "job"
+	}
+
 	topSectionMarkdwn := fmt.Sprintf(
-		":warning: Your application %s crashed on Porter. <%s|View the incident.>",
+		":warning: Your %s %s crashed on Porter. <%s|View the incident.>",
+		resourceKind,
 		"`"+incident.ReleaseName+"`",
 		url,
 	)