diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2019-01-03 18:56:22 +0100 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2019-01-03 18:56:22 +0100 |
commit | 1290f4f61d3d7eca42be17aa1c16805cfca62a13 (patch) | |
tree | 4746e2d2d0cc94fe6d4f6f2f43bea0a8c08d67a8 /config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java | |
parent | cea4ddb1d2d8b3ae8a51b99fb92fa73cd1964807 (diff) |
Move Notifications to upper level
Diffstat (limited to 'config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java')
-rw-r--r-- | config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java | 104 |
1 files changed, 0 insertions, 104 deletions
diff --git a/config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java b/config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java index bdc9e41c85d..a6cecefe940 100644 --- a/config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java +++ b/config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java @@ -2,7 +2,6 @@ package com.yahoo.config.application.api; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.yahoo.config.application.api.xml.DeploymentSpecXmlReader; import com.yahoo.config.provision.AthenzDomain; import com.yahoo.config.provision.AthenzService; @@ -18,7 +17,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; @@ -457,106 +455,4 @@ public class DeploymentSpec { } - /** - * Configuration of notifications for deployment jobs. - * - * Supports a list of email addresses, and a list of roles for which email addresses are known. - * The currently supported roles are: - * <ul> - * <li><strong>author</strong>: the author of the git commit of a given application package. </li> - * </ul> - */ - public static class Notifications { - - private static final Notifications none = new Notifications(Collections.emptyMap(), Collections.emptyMap()); - public static Notifications none() { return none; } - - private final Map<String, When> staticEmails; - private final Map<Role, When> roleEmails; - - private Notifications(Map<String, When> staticEmails, Map<Role, When> roleEmails) { - this.staticEmails = ImmutableMap.copyOf(staticEmails); - this.roleEmails = ImmutableMap.copyOf(roleEmails); - } - - /** - * Returns a new Notifications as specified by the given String input. - * - * @param when Optional string name of the default condition for sending notifications; defaults to failingCommit. - * @param staticEmails Map from email addresses to optional overrides for when to send to these. - * @param roleEmails Map from email roles to optional overrides for when to send to these. - * @return The Notifications as specified. - */ - public static Notifications of(Optional<String> when, Map<String, Optional<String>> staticEmails, Map<String, Optional<String>> roleEmails) { - if (staticEmails.isEmpty() && roleEmails.isEmpty()) - return none; - - When defaultWhen = when.map(When::fromValue).orElse(When.failingCommit); - return new Notifications(staticEmails.entrySet().stream() - .collect(Collectors.toMap(entry -> entry.getKey(), - entry -> entry.getValue().map(When::fromValue).orElse(defaultWhen))), - roleEmails.entrySet().stream() - .collect(Collectors.toMap(entry -> Role.fromValue(entry.getKey()), - entry -> entry.getValue().map(When::fromValue).orElse(defaultWhen)))); - } - - public Map<String, When> staticEmails() { - return staticEmails; - } - - public Map<Role, When> roleEmails() { - return roleEmails; - } - - - public enum Role { - - /** Author of the last commit of an application package. */ - author; - - public static String toValue(Role role) { - switch (role) { - case author: return "author"; - default: throw new IllegalArgumentException("Unexpected constant '" + role.name() + "'."); - } - } - - public static Role fromValue(String value) { - switch (value) { - case "author": return author; - default: throw new IllegalArgumentException("Unknown value '" + value + "'."); - } - } - - } - - - public enum When { - - /** Send notifications whenever a job fails. */ - failing, - - /** Send notifications whenever a job fails while deploying a new commit. */ - failingCommit; - - public static String toValue(When when) { - switch (when) { - case failing: return "failing"; - case failingCommit: return "failing-commit"; - default: throw new IllegalArgumentException("Unexpected constant '" + when.name() + "'."); - } - } - - public static When fromValue(String value) { - switch (value) { - case "failing": return failing; - case "failing-commit": return failingCommit; - default: throw new IllegalArgumentException("Unknown value '" + value + "'."); - } - } - - } - - } - } |