Admin: Fix broken links to image assets in email templates (#58729)

fix broken links to image assets
This commit is contained in:
matt abrams
2022-11-16 14:17:39 +01:00
committed by GitHub
parent f2cb248d93
commit 74010fd05d
19 changed files with 40 additions and 40 deletions
+1 -1
View File
@@ -124,7 +124,7 @@ func (dn *DiscordNotifier) Notify(evalContext *alerting.EvalContext) error {
footer := map[string]interface{}{
"text": "Grafana v" + setting.BuildVersion,
"icon_url": "https://grafana.com/assets/img/fav32.png",
"icon_url": "https://grafana.com/static/assets/img/fav32.png",
}
color, _ := strconv.ParseInt(strings.TrimLeft(evalContext.GetStateModel().Color, "#"), 16, 0)
+1 -1
View File
@@ -148,7 +148,7 @@ func (hc *HipChatNotifier) Notify(evalContext *alerting.EvalContext) error {
"title": evalContext.GetNotificationTitle(),
"description": message,
"icon": map[string]interface{}{
"url": "https://grafana.com/assets/img/fav32.png",
"url": "https://grafana.com/static/assets/img/fav32.png",
},
"date": evalContext.EndTime.Unix(),
"attributes": attributes,
+1 -1
View File
@@ -284,7 +284,7 @@ func (sn *SlackNotifier) Notify(evalContext *alerting.EvalContext) error {
"fallback": evalContext.GetNotificationTitle(),
"fields": fields,
"footer": "Grafana v" + setting.BuildVersion,
"footer_icon": "https://grafana.com/assets/img/fav32.png",
"footer_icon": "https://grafana.com/static/assets/img/fav32.png",
"ts": time.Now().Unix(),
}
if sn.NeedsImage() && imageURL != "" {
+1 -1
View File
@@ -60,7 +60,7 @@ func createTestEvalContext(cmd *NotificationTestCommand) *EvalContext {
ctx := NewEvalContext(context.Background(), testRule, fakeRequestValidator{}, nil, nil, nil, annotationstest.NewFakeAnnotationsRepo())
if cmd.Settings.Get("uploadImage").MustBool(true) {
ctx.ImagePublicURL = "https://grafana.com/assets/img/blog/mixed_styles.png"
ctx.ImagePublicURL = "https://grafana.com/static/assets/img/blog/mixed_styles.png"
}
ctx.IsTestRun = true
ctx.Firing = true
@@ -121,7 +121,7 @@ func (d DiscordNotifier) Notify(ctx context.Context, as ...*types.Alert) (bool,
footer := map[string]interface{}{
"text": "Grafana v" + setting.BuildVersion,
"icon_url": "https://grafana.com/assets/img/fav32.png",
"icon_url": "https://grafana.com/static/assets/img/fav32.png",
}
linkEmbed := simplejson.New()
@@ -46,7 +46,7 @@ func TestDiscordNotifier(t *testing.T) {
"embeds": []interface{}{map[string]interface{}{
"color": 1.4037554e+07,
"footer": map[string]interface{}{
"icon_url": "https://grafana.com/assets/img/fav32.png",
"icon_url": "https://grafana.com/static/assets/img/fav32.png",
"text": "Grafana v" + setting.BuildVersion,
},
"title": "[FIRING:1] (val1)",
@@ -73,7 +73,7 @@ func TestDiscordNotifier(t *testing.T) {
"embeds": []interface{}{map[string]interface{}{
"color": 1.4037554e+07,
"footer": map[string]interface{}{
"icon_url": "https://grafana.com/assets/img/fav32.png",
"icon_url": "https://grafana.com/static/assets/img/fav32.png",
"text": "Grafana v" + setting.BuildVersion,
},
"title": "Alerts firing: 1",
@@ -87,7 +87,7 @@ func TestDiscordNotifier(t *testing.T) {
{
name: "Missing field in template",
settings: `{
"avatar_url": "https://grafana.com/assets/img/fav32.png",
"avatar_url": "https://grafana.com/static/assets/img/fav32.png",
"url": "http://localhost",
"message": "I'm a custom template {{ .NotAField }} bad template"
}`,
@@ -100,12 +100,12 @@ func TestDiscordNotifier(t *testing.T) {
},
},
expMsg: map[string]interface{}{
"avatar_url": "https://grafana.com/assets/img/fav32.png",
"avatar_url": "https://grafana.com/static/assets/img/fav32.png",
"content": "I'm a custom template ",
"embeds": []interface{}{map[string]interface{}{
"color": 1.4037554e+07,
"footer": map[string]interface{}{
"icon_url": "https://grafana.com/assets/img/fav32.png",
"icon_url": "https://grafana.com/static/assets/img/fav32.png",
"text": "Grafana v" + setting.BuildVersion,
},
"title": "[FIRING:1] (val1)",
@@ -119,7 +119,7 @@ func TestDiscordNotifier(t *testing.T) {
{
name: "Invalid message template",
settings: `{
"avatar_url": "https://grafana.com/assets/img/fav32.png",
"avatar_url": "https://grafana.com/static/assets/img/fav32.png",
"url": "http://localhost",
"message": "{{ template \"invalid.template\" }}"
}`,
@@ -132,12 +132,12 @@ func TestDiscordNotifier(t *testing.T) {
},
},
expMsg: map[string]interface{}{
"avatar_url": "https://grafana.com/assets/img/fav32.png",
"avatar_url": "https://grafana.com/static/assets/img/fav32.png",
"content": "",
"embeds": []interface{}{map[string]interface{}{
"color": 1.4037554e+07,
"footer": map[string]interface{}{
"icon_url": "https://grafana.com/assets/img/fav32.png",
"icon_url": "https://grafana.com/static/assets/img/fav32.png",
"text": "Grafana v" + setting.BuildVersion,
},
"title": "[FIRING:1] (val1)",
@@ -169,7 +169,7 @@ func TestDiscordNotifier(t *testing.T) {
"embeds": []interface{}{map[string]interface{}{
"color": 1.4037554e+07,
"footer": map[string]interface{}{
"icon_url": "https://grafana.com/assets/img/fav32.png",
"icon_url": "https://grafana.com/static/assets/img/fav32.png",
"text": "Grafana v" + setting.BuildVersion,
},
"title": "[FIRING:1] (val1)",
@@ -183,7 +183,7 @@ func TestDiscordNotifier(t *testing.T) {
{
name: "Invalid URL template",
settings: `{
"avatar_url": "https://grafana.com/assets/img/fav32.png",
"avatar_url": "https://grafana.com/static/assets/img/fav32.png",
"url": "http://localhost?q={{invalid }}}",
"message": "valid message"
}`,
@@ -196,12 +196,12 @@ func TestDiscordNotifier(t *testing.T) {
},
},
expMsg: map[string]interface{}{
"avatar_url": "https://grafana.com/assets/img/fav32.png",
"avatar_url": "https://grafana.com/static/assets/img/fav32.png",
"content": "valid message",
"embeds": []interface{}{map[string]interface{}{
"color": 1.4037554e+07,
"footer": map[string]interface{}{
"icon_url": "https://grafana.com/assets/img/fav32.png",
"icon_url": "https://grafana.com/static/assets/img/fav32.png",
"text": "Grafana v" + setting.BuildVersion,
},
"title": "[FIRING:1] (val1)",
@@ -215,7 +215,7 @@ func TestDiscordNotifier(t *testing.T) {
{
name: "Custom config with multiple alerts",
settings: `{
"avatar_url": "https://grafana.com/assets/img/fav32.png",
"avatar_url": "https://grafana.com/static/assets/img/fav32.png",
"url": "http://localhost",
"message": "{{ len .Alerts.Firing }} alerts are firing, {{ len .Alerts.Resolved }} are resolved"
}`,
@@ -233,12 +233,12 @@ func TestDiscordNotifier(t *testing.T) {
},
},
expMsg: map[string]interface{}{
"avatar_url": "https://grafana.com/assets/img/fav32.png",
"avatar_url": "https://grafana.com/static/assets/img/fav32.png",
"content": "2 alerts are firing, 0 are resolved",
"embeds": []interface{}{map[string]interface{}{
"color": 1.4037554e+07,
"footer": map[string]interface{}{
"icon_url": "https://grafana.com/assets/img/fav32.png",
"icon_url": "https://grafana.com/static/assets/img/fav32.png",
"text": "Grafana v" + setting.BuildVersion,
},
"title": "[FIRING:2] ",
@@ -273,7 +273,7 @@ func TestDiscordNotifier(t *testing.T) {
"embeds": []interface{}{map[string]interface{}{
"color": 1.4037554e+07,
"footer": map[string]interface{}{
"icon_url": "https://grafana.com/assets/img/fav32.png",
"icon_url": "https://grafana.com/static/assets/img/fav32.png",
"text": "Grafana v" + setting.BuildVersion,
},
"title": "[FIRING:1] (val1)",
@@ -74,7 +74,7 @@ func TestSlackNotifier(t *testing.T) {
Fallback: "[FIRING:1] (val1)",
Fields: nil,
Footer: "Grafana v" + setting.BuildVersion,
FooterIcon: "https://grafana.com/assets/img/fav32.png",
FooterIcon: "https://grafana.com/static/assets/img/fav32.png",
Color: "#D63232",
Ts: 0,
},
@@ -109,7 +109,7 @@ func TestSlackNotifier(t *testing.T) {
Fallback: "[FIRING:1] (val1)",
Fields: nil,
Footer: "Grafana v" + setting.BuildVersion,
FooterIcon: "https://grafana.com/assets/img/fav32.png",
FooterIcon: "https://grafana.com/static/assets/img/fav32.png",
Color: "#D63232",
Ts: 0,
},
@@ -144,7 +144,7 @@ func TestSlackNotifier(t *testing.T) {
Fallback: "[FIRING:1] (val1)",
Fields: nil,
Footer: "Grafana v" + setting.BuildVersion,
FooterIcon: "https://grafana.com/assets/img/fav32.png",
FooterIcon: "https://grafana.com/static/assets/img/fav32.png",
Color: "#D63232",
Ts: 0,
ImageURL: "https://www.example.com/image.jpg",
@@ -187,7 +187,7 @@ func TestSlackNotifier(t *testing.T) {
Fallback: "2 firing, 0 resolved",
Fields: nil,
Footer: "Grafana v" + setting.BuildVersion,
FooterIcon: "https://grafana.com/assets/img/fav32.png",
FooterIcon: "https://grafana.com/static/assets/img/fav32.png",
Color: "#D63232",
Ts: 0,
},
@@ -235,7 +235,7 @@ func TestSlackNotifier(t *testing.T) {
Fallback: "[FIRING:1] (val1)",
Fields: nil,
Footer: "Grafana v" + setting.BuildVersion,
FooterIcon: "https://grafana.com/assets/img/fav32.png",
FooterIcon: "https://grafana.com/static/assets/img/fav32.png",
Color: "#D63232",
Ts: 0,
},
@@ -30,7 +30,7 @@ import (
)
const (
FooterIconURL = "https://grafana.com/assets/img/fav32.png"
FooterIconURL = "https://grafana.com/static/assets/img/fav32.png"
ColorAlertFiring = "#D63232"
ColorAlertResolved = "#36a64f"
@@ -2322,7 +2322,7 @@ var expNonEmailNotifications = map[string][]string{
"text": "Integration Test ",
"fallback": "Integration Test [FIRING:1] SlackAlert1 (default)",
"footer": "Grafana v",
"footer_icon": "https://grafana.com/assets/img/fav32.png",
"footer_icon": "https://grafana.com/static/assets/img/fav32.png",
"color": "#D63232",
"ts": %s,
"mrkdwn_in": ["pretext"],
@@ -2342,7 +2342,7 @@ var expNonEmailNotifications = map[string][]string{
"text": "**Firing**\n\nValue: A=1\nLabels:\n - alertname = SlackAlert2\n - grafana_folder = default\nAnnotations:\nSource: http://localhost:3000/alerting/grafana/UID_SlackAlert2/view\nSilence: http://localhost:3000/alerting/silence/new?alertmanager=grafana&matcher=alertname%%3DSlackAlert2&matcher=grafana_folder%%3Ddefault\n",
"fallback": "[FIRING:1] SlackAlert2 (default)",
"footer": "Grafana v",
"footer_icon": "https://grafana.com/assets/img/fav32.png",
"footer_icon": "https://grafana.com/static/assets/img/fav32.png",
"color": "#D63232",
"ts": %s,
"mrkdwn_in": ["pretext"],
@@ -2480,7 +2480,7 @@ var expNonEmailNotifications = map[string][]string{
{
"color": 14037554,
"footer": {
"icon_url": "https://grafana.com/assets/img/fav32.png",
"icon_url": "https://grafana.com/static/assets/img/fav32.png",
"text": "Grafana v"
},
"title": "[FIRING:1] DiscordAlert (default)",