Skip to content

Commit

Permalink
chore(kayenta): use StageGraphBuilder.append where it's simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
robfletcher committed Apr 6, 2018
1 parent 10db83b commit ef91d0c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,11 @@ abstract class TargetServerGroupLinearStageSupport implements StageDefinitionBui
def targets = resolver.resolveByParams(params)
def descriptionList = buildStaticTargetDescriptions(stage, targets)

descriptionList.inject(null) { Stage previous, Map<String, Object> description ->
if (previous == null) {
graph.add {
it.type = type
it.name = name
it.context = description
}
} else {
graph.connect(previous) {
it.type = type
it.name = name
it.context = description
}
descriptionList.each { Map<String, Object> description ->
graph.append {
it.type = type
it.name = name
it.context = description
}
}
}
Expand All @@ -180,15 +172,15 @@ abstract class TargetServerGroupLinearStageSupport implements StageDefinitionBui
def singularLocationType = params.locations[0].singularType()
def pluralLocationType = params.locations[0].pluralType()

def determineTargetServerGroups = graph.add {
graph.add {
it.type = DetermineTargetServerGroupStage.PIPELINE_CONFIG_TYPE
it.name = DetermineTargetServerGroupStage.PIPELINE_CONFIG_TYPE
it.context.putAll(stage.context)
it.context[pluralLocationType] = params.locations.collect { it.value }
}

params.locations.inject(determineTargetServerGroups) { Stage previous, Location location ->
graph.connect(previous) {
params.locations.each { Location location ->
graph.append {
it.type = type
it.name = name
it.context.putAll(stage.context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import javax.annotation.Nonnull
import com.netflix.frigga.autoscaling.AutoScalingGroupNameBuilder
import com.netflix.spinnaker.kork.core.RetrySupport
import com.netflix.spinnaker.orca.CancellableStage
import com.netflix.spinnaker.orca.CancellableStage.Result
import com.netflix.spinnaker.orca.clouddriver.KatoService
import com.netflix.spinnaker.orca.clouddriver.tasks.servergroup.DestroyServerGroupTask
import com.netflix.spinnaker.orca.clouddriver.utils.OortHelper
Expand Down Expand Up @@ -55,12 +54,12 @@ class CanaryStage implements StageDefinitionBuilder, CancellableStage {
Map<String, Object> deployContext = canaryStageId + parent.context
Map<String, Object> monitorContext = canaryStageId + [scaleUp: parent.context.scaleUp ?: [:]]

def deployCanaryStage = graph.add {
graph.append {
it.type = deployCanaryStage.type
it.name = "Deploy Canary"
it.context = deployContext
}
graph.connect(deployCanaryStage) {
graph.append {
it.type = monitorCanaryStage.type
it.name = "Monitor Canary"
it.context = monitorContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ val stageWithSyntheticOnFailure = object : StageDefinitionBuilder {
}

override fun onFailureStages(stage: Stage, graph: StageGraphBuilder) {
val stage1 = graph.add {
graph.append {
it.type = singleTaskStage.type
it.name = "onFailure1"
it.context = stage.context
}
graph.connect(stage1) {
graph.append {
it.type = singleTaskStage.type
it.name = "onFailure2"
it.context = stage.context
Expand Down Expand Up @@ -103,12 +103,12 @@ val stageWithSyntheticAfter = object : StageDefinitionBuilder {
}

override fun afterStages(parent: Stage, graph: StageGraphBuilder) {
val first = graph.add {
graph.append {
it.type = singleTaskStage.type
it.name = "post1"
it.context = parent.context
}
graph.connect(first) {
graph.append {
it.type = singleTaskStage.type
it.name = "post2"
it.context = parent.context
Expand Down

0 comments on commit ef91d0c

Please sign in to comment.