Skip to content

Commit

Permalink
refactor(strategies): clean up some strategies from my past refactor (#…
Browse files Browse the repository at this point in the history
…3213)

also, remove a deprecated class
  • Loading branch information
marchello2000 authored Oct 7, 2019
1 parent 967ed79 commit 72b08f2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,11 @@ class CustomStrategy implements Strategy {

@Override
List<Stage> composeBeforeStages(Stage parent) {
return composeFlow(parent)
.findAll({ it.syntheticStageOwner == SyntheticStageOwner.STAGE_BEFORE })
return Collections.emptyList()
}

@Override
List<Stage> composeAfterStages(Stage parent) {
return composeFlow(parent)
.findAll({ it.syntheticStageOwner == SyntheticStageOwner.STAGE_AFTER })
}

List<Stage> composeFlow(Stage stage) {
List<Stage> composeAfterStages(Stage stage) {
def cleanupConfig = AbstractDeployStrategyStage.CleanupConfig.fromStage(stage)

Map parameters = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,11 @@ class HighlanderStrategy implements Strategy, ApplicationContextAware {

@Override
List<Stage> composeBeforeStages(Stage parent) {
return composeFlow(parent)
.findAll({ it.syntheticStageOwner == SyntheticStageOwner.STAGE_BEFORE })
return Collections.emptyList()
}

@Override
List<Stage> composeAfterStages(Stage parent) {
return composeFlow(parent)
.findAll({ it.syntheticStageOwner == SyntheticStageOwner.STAGE_AFTER })
}

List<Stage> composeFlow(Stage stage) {
List<Stage> composeAfterStages(Stage stage) {
def cleanupConfig = AbstractDeployStrategyStage.CleanupConfig.fromStage(stage)
Map shrinkContext = [
(cleanupConfig.location.singularType()): cleanupConfig.location.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.netflix.spinnaker.orca.clouddriver.pipeline.servergroup.strategies

import com.netflix.spinnaker.kork.exceptions.UserException
import com.netflix.spinnaker.orca.kato.pipeline.ModifyAsgLaunchConfigurationStage
import com.netflix.spinnaker.orca.kato.pipeline.RollingPushStage
import com.netflix.spinnaker.orca.kato.pipeline.support.SourceResolver
Expand Down Expand Up @@ -43,22 +44,22 @@ class RollingPushStrategy implements Strategy {

@Override
List<Stage> composeBeforeStages(Stage parent) {
return composeFlow(parent)
.findAll({ it.syntheticStageOwner == SyntheticStageOwner.STAGE_BEFORE })
}
def source = sourceResolver.getSource(parent)

@Override
List<Stage> composeAfterStages(Stage parent) {
return composeFlow(parent)
.findAll({ it.syntheticStageOwner == SyntheticStageOwner.STAGE_AFTER })
if (!source) {
throw new UserException("Could not find source server group for rolling push. Does the specified cluster exist?")
}

return Collections.emptyList()
}

List<Stage> composeFlow(Stage stage) {
@Override
List<Stage> composeAfterStages(Stage stage) {
def stages = []
def source = sourceResolver.getSource(stage)

if (!source) {
throw new IllegalArgumentException("Could not find source server group for rolling push. Does the specified cluster exist?")
throw new UserException("Could not find source server group for rolling push. Does the specified cluster exist?")
}

def modifyCtx = stage.context + [
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ class HighlanderStrategySpec extends Specification {
def strat = new HighlanderStrategy(shrinkClusterStage: shrinkClusterStage)

when:
def syntheticStages = strat.composeFlow(stage)
def beforeStages = syntheticStages.findAll { it.syntheticStageOwner == SyntheticStageOwner.STAGE_BEFORE }
def afterStages = syntheticStages.findAll { it.syntheticStageOwner == SyntheticStageOwner.STAGE_AFTER }
def beforeStages = strat.composeBeforeStages(stage)
def afterStages = strat.composeAfterStages(stage)

then:
beforeStages.isEmpty()
Expand Down

0 comments on commit 72b08f2

Please sign in to comment.