Skip to content

Commit

Permalink
feat(provider/kubernetes): insert artifacts during deploy (#1823)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwander authored Nov 29, 2017
1 parent 8fedbaf commit 8eed431
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
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

0 comments on commit 8eed431

Please sign in to comment.