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(provider/kubernetes): insert artifacts during deploy #1823

Merged
merged 1 commit into from
Nov 29, 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 @@ -18,21 +18,29 @@
package com.netflix.spinnaker.orca.clouddriver.tasks.manifest;

import com.google.common.collect.ImmutableMap;
import com.netflix.spinnaker.kork.artifacts.model.Artifact;
import com.netflix.spinnaker.orca.ExecutionStatus;
import com.netflix.spinnaker.orca.Task;
import com.netflix.spinnaker.orca.TaskResult;
import com.netflix.spinnaker.orca.clouddriver.KatoService;
import com.netflix.spinnaker.orca.clouddriver.model.TaskId;
import com.netflix.spinnaker.orca.clouddriver.tasks.AbstractCloudProviderAwareTask;
import com.netflix.spinnaker.orca.pipeline.model.Stage;
import com.netflix.spinnaker.orca.pipeline.model.StageContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Component
@Slf4j
public class DeployManifestTask extends AbstractCloudProviderAwareTask implements Task {
@Autowired
KatoService kato;
Expand All @@ -44,10 +52,25 @@ public class DeployManifestTask extends AbstractCloudProviderAwareTask implement
public TaskResult execute(@Nonnull Stage stage) {
String credentials = getCredentials(stage);
String cloudProvider = getCloudProvider(stage);

List<Object> artifacts = new ArrayList<>();
if (stage.getContext() instanceof StageContext) {
artifacts = (List<Object>) ((StageContext) stage.getContext()).getAll("artifacts")
.stream()
.filter(a -> a instanceof List)
.flatMap(x -> ((List) x).stream())
.collect(Collectors.toList());
} else {
log.warn("Unable to read artifacts from unknown context type: {} ({})", stage.getContext().getClass(), stage.getExecution().getId());
}

Map task = new HashMap(stage.getContext());
task.put("artifacts", artifacts);
Map<String, Map> operation = new ImmutableMap.Builder<String, Map>()
.put(TASK_NAME, stage.getContext())
.put(TASK_NAME, task)
.build();

System.out.println("op = " + operation.keySet());
TaskId taskId = kato.requestOperations(cloudProvider, Collections.singletonList(operation)).toBlocking().first();

Map<String, Object> outputs = new ImmutableMap.Builder<String, Object>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public List<Object> getAll(Object key) {

Map<String, Object> trigger = getTrigger();
if (trigger.containsKey(key)) {
result.add(key);
result.add(trigger.get(key));
}

return result;
Expand Down