From 513b1ead86535aef4cbbd2bc6f081b31ff07b8d1 Mon Sep 17 00:00:00 2001 From: Asher Feldman Date: Mon, 4 Dec 2017 16:42:56 -0800 Subject: [PATCH] fix(moniker): fix cluster if detail is set to empty via SpEL --- .../spinnaker/orca/clouddriver/utils/MonikerHelper.java | 7 ++++++- .../spinnaker/orca/kato/pipeline/support/StageData.groovy | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/clouddriver/utils/MonikerHelper.java b/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/clouddriver/utils/MonikerHelper.java index 8bd8c71160..a259c8d41a 100644 --- a/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/clouddriver/utils/MonikerHelper.java +++ b/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/clouddriver/utils/MonikerHelper.java @@ -21,6 +21,7 @@ import com.netflix.spinnaker.orca.clouddriver.pipeline.servergroup.support.TargetServerGroup; import com.netflix.spinnaker.orca.clouddriver.pipeline.servergroup.support.TargetServerGroupResolver; import com.netflix.spinnaker.orca.pipeline.model.Stage; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; @@ -56,7 +57,11 @@ public String getClusterNameFromStage(Stage stage, String fallbackFriggaName) { static public Moniker monikerFromStage(Stage stage) { if (stage.getContext().containsKey("moniker")) { - return (Moniker) stage.mapTo("/moniker", Moniker.class); + Moniker moniker = stage.mapTo("/moniker", Moniker.class); + if (moniker.getCluster().endsWith("-")) { + moniker.setCluster(StringUtils.stripEnd(moniker.getCluster(), "-")); + } + return moniker; } else { return null; } diff --git a/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/kato/pipeline/support/StageData.groovy b/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/kato/pipeline/support/StageData.groovy index ce51bb8510..0820ad9d65 100644 --- a/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/kato/pipeline/support/StageData.groovy +++ b/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/kato/pipeline/support/StageData.groovy @@ -18,6 +18,7 @@ package com.netflix.spinnaker.orca.kato.pipeline.support import com.netflix.frigga.autoscaling.AutoScalingGroupNameBuilder import com.netflix.spinnaker.moniker.Moniker +import org.apache.commons.lang3.StringUtils class StageData { String strategy @@ -47,7 +48,7 @@ class StageData { String getCluster() { if (moniker?.cluster) { - return moniker.cluster + return StringUtils.stripEnd(moniker.cluster, "-") } else { def builder = new AutoScalingGroupNameBuilder() builder.appName = application