diff --git a/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/clouddriver/tasks/manifest/DeployManifestTask.java b/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/clouddriver/tasks/manifest/DeployManifestTask.java index 59ea758291..81668d8d8e 100644 --- a/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/clouddriver/tasks/manifest/DeployManifestTask.java +++ b/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/clouddriver/tasks/manifest/DeployManifestTask.java @@ -18,6 +18,7 @@ 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; @@ -25,14 +26,21 @@ 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; @@ -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 artifacts = new ArrayList<>(); + if (stage.getContext() instanceof StageContext) { + artifacts = (List) ((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 operation = new ImmutableMap.Builder() - .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 outputs = new ImmutableMap.Builder() diff --git a/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/model/StageContext.java b/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/model/StageContext.java index 03db42e082..f53790433c 100644 --- a/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/model/StageContext.java +++ b/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/model/StageContext.java @@ -86,7 +86,7 @@ public List getAll(Object key) { Map trigger = getTrigger(); if (trigger.containsKey(key)) { - result.add(key); + result.add(trigger.get(key)); } return result;