Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(moniker): Use moniker for Rollingpush tasks. #1703

Merged
merged 7 commits into from
Oct 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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