Skip to content

Commit

Permalink
feat(moniker): Use moniker for Rollingpush tasks. (#1703)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbackes authored and lwander committed Oct 25, 2017
1 parent 1a0ed90 commit a24986c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
import java.util.function.Predicate;
import java.util.stream.Collectors;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.netflix.frigga.Names;
import com.netflix.spinnaker.orca.ExecutionStatus;
import com.netflix.spinnaker.orca.RetryableTask;
import com.netflix.spinnaker.orca.TaskResult;
import com.netflix.spinnaker.orca.clouddriver.KatoService;
import com.netflix.spinnaker.orca.clouddriver.OortService;
import com.netflix.spinnaker.orca.clouddriver.model.TaskId;
import com.netflix.spinnaker.orca.clouddriver.tasks.AbstractCloudProviderAwareTask;
import com.netflix.spinnaker.orca.clouddriver.utils.MonikerHelper;
import com.netflix.spinnaker.orca.kato.pipeline.support.SourceResolver;
import com.netflix.spinnaker.orca.kato.pipeline.support.StageData;
import com.netflix.spinnaker.orca.pipeline.model.Stage;
Expand All @@ -55,18 +55,20 @@ public class CleanUpTagsTask extends AbstractCloudProviderAwareTask implements R
@Autowired
ObjectMapper objectMapper;

@Autowired
MonikerHelper monikerHelper;

@Override
public TaskResult execute(Stage stage) {
try {
StageData.Source source = sourceResolver.getSource(stage);
String serverGroupName = Optional.ofNullable(source.getServerGroupName()).orElse(source.getAsgName());
Names name = Names.parseName(serverGroupName);
String cloudProvider = getCloudProvider(stage);

Response serverGroupResponse = oortService.getServerGroupFromCluster(
name.getApp(),
monikerHelper.getAppNameFromStage(stage, serverGroupName),
source.getAccount(),
name.getCluster(),
monikerHelper.getClusterNameFromStage(stage, serverGroupName),
serverGroupName,
source.getRegion(),
cloudProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper
import com.netflix.spinnaker.orca.clouddriver.KatoService
import com.netflix.spinnaker.orca.clouddriver.OortService
import com.netflix.spinnaker.orca.clouddriver.model.TaskId
import com.netflix.spinnaker.orca.clouddriver.utils.MonikerHelper
import com.netflix.spinnaker.orca.kato.pipeline.support.SourceResolver
import com.netflix.spinnaker.orca.pipeline.model.Pipeline
import com.netflix.spinnaker.orca.pipeline.model.Stage
Expand Down Expand Up @@ -70,6 +71,15 @@ class CleanUpTagsTaskSpec extends Specification {

List<Map> operations = []
task.objectMapper = new ObjectMapper();
task.monikerHelper = Mock(MonikerHelper) {
1* getAppNameFromStage(stage, "app-v00") >> {
"app"
}
1* getClusterNameFromStage(stage, "app-v00") >> {
"app"
}
0 * _
}
task.oortService = Mock(OortService) {
1* getServerGroupFromCluster("app","test", "app", "app-v00", "us-east-1", "aws") >> {
oortResponse
Expand Down

0 comments on commit a24986c

Please sign in to comment.