Skip to content

Commit

Permalink
fix(notifications): fix editing notifications in halyard (spinnaker#1413
Browse files Browse the repository at this point in the history
  • Loading branch information
plumpy authored and Anton Malinskiy committed Sep 19, 2019
1 parent 7ccf726 commit 160c64d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public enum NotificationType {
this.name = name;
}

public String getName() {
return name;
}

@Override
public String toString() {
return name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@

package com.netflix.spinnaker.halyard.config.model.v1.node;

import static com.google.common.base.Preconditions.checkArgument;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.netflix.spinnaker.halyard.config.model.v1.node.Notification.NotificationType;
import com.netflix.spinnaker.halyard.config.model.v1.notifications.GithubStatusNotification;
import com.netflix.spinnaker.halyard.config.model.v1.notifications.SlackNotification;
import com.netflix.spinnaker.halyard.config.model.v1.notifications.TwilioNotification;
import java.util.Optional;
import java.util.stream.Stream;
import lombok.Data;
import lombok.EqualsAndHashCode;

Expand All @@ -46,8 +51,18 @@ public boolean isEnabled() {
}

public static Class<? extends Notification> translateNotificationType(String notificationName) {
Class<? extends Notification> n;
switch (Notification.NotificationType.valueOf(notificationName)) {

Optional<NotificationType> notificationType =
Stream.of(NotificationType.values())
.filter(type -> type.getName().equals(notificationName))
.findAny();

checkArgument(
notificationType.isPresent(),
"No notification type with name %s handled by halyard",
notificationName);

switch (notificationType.get()) {
case SLACK:
return SlackNotification.class;
case TWILIO:
Expand Down

0 comments on commit 160c64d

Please sign in to comment.