Procházet zdrojové kódy

clean up slack notifications

Alexander Belanger před 4 roky
rodič
revize
dc122bc62d

+ 11 - 1
api/server/handlers/kube_events/create.go

@@ -2,7 +2,9 @@ package kube_events
 
 import (
 	"errors"
+	"fmt"
 	"net/http"
+	"net/url"
 	"strings"
 	"time"
 
@@ -146,7 +148,15 @@ func notifyPodCrashing(
 		ClusterName: cluster.Name,
 		Name:        event.OwnerName,
 		Namespace:   event.Namespace,
-		URL:         config.ServerConf.ServerURL,
+		Info:        fmt.Sprintf("%s:%s", event.Reason, event.Message),
+		URL: fmt.Sprintf(
+			"%s/applications/%s/%s/%s?project_id=%d",
+			config.ServerConf.ServerURL,
+			url.PathEscape(cluster.Name),
+			matchedRel.Namespace,
+			matchedRel.Name,
+			cluster.ProjectID,
+		),
 	}
 
 	notifyOpts.Status = slack.StatusPodCrashed

+ 4 - 3
api/server/handlers/release/ugprade.go

@@ -144,12 +144,13 @@ func (c *UpgradeReleaseHandler) ServeHTTP(w http.ResponseWriter, r *http.Request
 		Name:        helmRelease.Name,
 		Namespace:   helmRelease.Namespace,
 		URL: fmt.Sprintf(
-			"%s/applications/%s/%s/%s",
+			"%s/applications/%s/%s/%s?project_id=%d",
 			c.Config().ServerConf.ServerURL,
 			url.PathEscape(cluster.Name),
-			cluster.Name,
+			helmRelease.Namespace,
 			helmRelease.Name,
-		) + fmt.Sprintf("?project_id=%d", cluster.ProjectID),
+			cluster.ProjectID,
+		),
 	}
 
 	if upgradeErr != nil {

+ 3 - 2
api/server/handlers/release/upgrade_webhook.go

@@ -157,12 +157,13 @@ func (c *WebhookHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 		Name:        rel.Name,
 		Namespace:   rel.Namespace,
 		URL: fmt.Sprintf(
-			"%s/applications/%s/%s/%s",
+			"%s/applications/%s/%s/%s?project_id=%d",
 			c.Config().ServerConf.ServerURL,
 			url.PathEscape(cluster.Name),
 			release.Namespace,
 			rel.Name,
-		) + fmt.Sprintf("?project_id=%d", release.ProjectID),
+			cluster.ProjectID,
+		),
 	}
 
 	rel, err = helmAgent.UpgradeReleaseByValues(conf, c.Config().DOConf)

+ 1 - 1
internal/integrations/slack/notifier.go

@@ -197,7 +197,7 @@ func getHelmMessageBlock(opts *NotifyOpts) *SlackBlock {
 
 func getPodCrashedMessageBlock(opts *NotifyOpts) *SlackBlock {
 	md := fmt.Sprintf(
-		":x: Your application %s crashed on Porter. <%s|View the new release.>",
+		":x: Your application %s crashed on Porter. <%s|View the application.>",
 		"`"+opts.Name+"`",
 		opts.URL,
 	)