summaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorValerij Fredriksen <freva@users.noreply.github.com>2022-06-30 14:53:12 +0200
committerGitHub <noreply@github.com>2022-06-30 14:53:12 +0200
commitce5a1c7de4b006a07c0ec73cab81c90e0eb1a5f0 (patch)
treef47e4d49e605da0f362cfe4ce1ae010740d27c13 /controller-server
parent6049047d68a0d355c1438a7b79205cfb9c8a0e48 (diff)
parent96dcfb0e8fe953357198001202687f433f2506c8 (diff)
Merge pull request #23291 from vespa-engine/ldalves/email-template
Add basic header to notification email
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notifier.java25
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/notification/NotifierTest.java22
2 files changed, 33 insertions, 14 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notifier.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notifier.java
index 49c819548fe..f2c9d55b2a2 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notifier.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notifier.java
@@ -29,6 +29,16 @@ import java.util.stream.Collectors;
* @author enygaard
*/
public class Notifier {
+ private static final String header = """
+ <div style="background: #00598c; height: 55px; width: 100%">
+ <img
+ src="https://vespa.ai/assets/vespa-logo.png"
+ style="width: auto; height: 34px; margin: 10px"
+ />
+ </div>
+ <br>
+ """;
+
private final CuratorDb curatorDb;
private final Mailer mailer;
private final FlagSource flagSource;
@@ -111,14 +121,15 @@ public class Notifier {
public Mail mailOf(FormattedNotification content, Collection<String> recipients) {
var notification = content.notification();
var subject = Text.format("[%s] %s Vespa Notification for %s", notification.level().toString().toUpperCase(), content.prettyType(), applicationIdSource(notification.source()));
- var body = new StringBuilder();
- body.append(content.messagePrefix()).append("\n")
+ String body = new StringBuilder()
+ .append(content.messagePrefix()).append("\n")
.append(notification.messages().stream().map(m -> " * " + m).collect(Collectors.joining("\n"))).append("\n")
.append("\n")
.append("Vespa Console link:\n")
- .append(content.uri().toString());
- var html = new StringBuilder();
- html.append(content.messagePrefix()).append("<br>\n")
+ .append(content.uri().toString()).toString();
+ String html = new StringBuilder()
+ .append(header)
+ .append(content.messagePrefix()).append("<br>\n")
.append("<ul>\n")
.append(notification.messages().stream()
.map(Notifier::linkify)
@@ -126,8 +137,8 @@ public class Notifier {
.collect(Collectors.joining("<br>\n")))
.append("</ul>\n")
.append("<br>\n")
- .append("<a href=\"" + content.uri() + "\">Vespa Console</a>");
- return new Mail(recipients, subject, body.toString(), html.toString());
+ .append("<a href=\"" + content.uri() + "\">Vespa Console</a>").toString();
+ return new Mail(recipients, subject, body, html);
}
@VisibleForTesting
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/notification/NotifierTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/notification/NotifierTest.java
index 8bf0e584892..4132db74140 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/notification/NotifierTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/notification/NotifierTest.java
@@ -68,12 +68,20 @@ public class NotifierTest {
var mail = mailer.inbox(email).get(0);
assertEquals("[WARNING] Test package Vespa Notification for tenant1.default.default", mail.subject());
- assertEquals("There are problems with tests for default.default<br>\n" +
- "<ul>\n" +
- "<li>test package has production tests, but no production tests are declared in deployment.xml</li><br>\n" +
- "<li>see <a href=\"https://docs.vespa.ai/en/testing.html\">https://docs.vespa.ai/en/testing.html</a> for details on how to write system tests for Vespa</li></ul>\n" +
- "<br>\n" +
- "<a href=\"https://dashboard.tld/tenant1/default\">Vespa Console</a>",
+ assertEquals("""
+ <div style="background: #00598c; height: 55px; width: 100%">
+ <img
+ src="https://vespa.ai/assets/vespa-logo.png"
+ style="width: auto; height: 34px; margin: 10px"
+ />
+ </div>
+ <br>
+ There are problems with tests for default.default<br>
+ <ul>
+ <li>test package has production tests, but no production tests are declared in deployment.xml</li><br>
+ <li>see <a href="https://docs.vespa.ai/en/testing.html">https://docs.vespa.ai/en/testing.html</a> for details on how to write system tests for Vespa</li></ul>
+ <br>
+ <a href="https://dashboard.tld/tenant1/default">Vespa Console</a>""",
mail.htmlMessage().get());
}
@@ -84,4 +92,4 @@ public class NotifierTest {
"No url.", "No url.");
data.forEach((input, expected) -> assertEquals(expected, Notifier.linkify(input)));
}
-} \ No newline at end of file
+}