From 5f7432b29707fdee0aedaa5eed22bba0b02fc73a Mon Sep 17 00:00:00 2001 From: Jacob Kiefer <jacobkiefer@google.com> Date: Mon, 25 Sep 2017 13:03:31 -0400 Subject: [PATCH] feat(artifacts): Add receivedArtifacts to Pipeline model. --- build.gradle | 2 +- orca-core/orca-core.gradle | 1 + .../spinnaker/orca/pipeline/ExecutionLauncher.java | 10 ++++++---- .../spinnaker/orca/pipeline/PipelineLauncher.java | 13 ++++++++----- .../spinnaker/orca/pipeline/model/Pipeline.java | 14 ++++++++++++++ .../orca/pipeline/model/PipelineBuilder.groovy | 8 ++++++++ .../jedis/JedisExecutionRepository.groovy | 2 ++ 7 files changed, 40 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index a81708b2b5..d51beafac6 100644 --- a/build.gradle +++ b/build.gradle @@ -34,7 +34,7 @@ allprojects { group = "com.netflix.spinnaker.orca" ext { - spinnakerDependenciesVersion = project.hasProperty('spinnakerDependenciesVersion') ? project.property('spinnakerDependenciesVersion') : '0.109.2' + spinnakerDependenciesVersion = project.hasProperty('spinnakerDependenciesVersion') ? project.property('spinnakerDependenciesVersion') : '0.110.5' } def checkLocalVersions = [spinnakerDependenciesVersion: spinnakerDependenciesVersion] diff --git a/orca-core/orca-core.gradle b/orca-core/orca-core.gradle index 2f3fa3f18d..f1a90ca485 100644 --- a/orca-core/orca-core.gradle +++ b/orca-core/orca-core.gradle @@ -35,6 +35,7 @@ dependencies { compile spinnaker.dependency('spectatorApi') compile spinnaker.dependency('kork') compile spinnaker.dependency('korkExceptions') + compile spinnaker.dependency('korkArtifacts') compile "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${spinnaker.version('jackson')}" compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${spinnaker.version('jackson')}" diff --git a/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/ExecutionLauncher.java b/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/ExecutionLauncher.java index da001ce78e..6c6902f780 100644 --- a/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/ExecutionLauncher.java +++ b/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/ExecutionLauncher.java @@ -16,10 +16,6 @@ package com.netflix.spinnaker.orca.pipeline; -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.function.Function; import com.fasterxml.jackson.databind.ObjectMapper; import com.netflix.spinnaker.orca.ExecutionStatus; import com.netflix.spinnaker.orca.pipeline.model.Execution; @@ -28,6 +24,12 @@ import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.function.Function; + import static java.lang.Boolean.parseBoolean; import static java.util.Collections.emptyList; import static java.util.Collections.emptyMap; diff --git a/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/PipelineLauncher.java b/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/PipelineLauncher.java index e47b8be5b3..ce2172b517 100644 --- a/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/PipelineLauncher.java +++ b/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/PipelineLauncher.java @@ -16,19 +16,21 @@ package com.netflix.spinnaker.orca.pipeline; -import java.io.IOException; -import java.io.Serializable; -import java.util.List; -import java.util.Map; -import java.util.Optional; import com.fasterxml.jackson.databind.ObjectMapper; import com.netflix.spectator.api.Registry; +import com.netflix.spinnaker.kork.artifacts.model.Artifact; import com.netflix.spinnaker.orca.pipeline.model.Execution.ExecutionEngine; import com.netflix.spinnaker.orca.pipeline.model.Pipeline; import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.io.IOException; +import java.io.Serializable; +import java.util.List; +import java.util.Map; +import java.util.Optional; + @Component public class PipelineLauncher extends ExecutionLauncher<Pipeline> { @@ -65,6 +67,7 @@ public PipelineLauncher(ObjectMapper objectMapper, .withNotifications((List<Map<String, Object>>) config.get("notifications")) .withExecutionEngine(getEnum(config, "executionEngine", ExecutionEngine.class)) .withOrigin(getString(config, "origin")) + .withReceivedArtifacts((List<Artifact>) config.get("receivedArtifacts")) .build(); } diff --git a/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/model/Pipeline.java b/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/model/Pipeline.java index caab97c95d..0f1c040784 100644 --- a/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/model/Pipeline.java +++ b/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/model/Pipeline.java @@ -26,6 +26,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.netflix.spectator.api.Registry; +import com.netflix.spinnaker.kork.artifacts.model.Artifact; public class Pipeline extends Execution<Pipeline> { @@ -42,6 +43,19 @@ public Pipeline( private String pipelineConfigId; + /** + * Artifacts produced from trigger events and injected into the pipeline context. + */ + private List<Artifact> receivedArtifacts = new ArrayList<>(); + + public void setReceivedArtifacts(List<Artifact> receivedArtifacts) { + this.receivedArtifacts = receivedArtifacts; + } + + public @Nonnull List<Artifact> getReceivedArtifacts() { + return receivedArtifacts; + } + public @Nullable String getPipelineConfigId() { return pipelineConfigId; } diff --git a/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/model/PipelineBuilder.groovy b/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/model/PipelineBuilder.groovy index 9539e23dbe..e4ec7289db 100644 --- a/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/model/PipelineBuilder.groovy +++ b/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/model/PipelineBuilder.groovy @@ -45,6 +45,14 @@ class PipelineBuilder { return this } + PipelineBuilder withReceivedArtifacts(List receivedArtifacts = []) { + pipeline.receivedArtifacts.clear() + if (receivedArtifacts) { + pipeline.receivedArtifacts.addAll(receivedArtifacts) + } + return this + } + PipelineBuilder withNotifications(List<Map<String, Object>> notifications = []) { pipeline.notifications.clear() if (notifications) { diff --git a/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/persistence/jedis/JedisExecutionRepository.groovy b/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/persistence/jedis/JedisExecutionRepository.groovy index 50d651c5bf..c1437fe15b 100644 --- a/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/persistence/jedis/JedisExecutionRepository.groovy +++ b/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/persistence/jedis/JedisExecutionRepository.groovy @@ -545,6 +545,7 @@ class JedisExecutionRepository implements ExecutionRepository { map.pipelineConfigId = execution.pipelineConfigId map.trigger = mapper.writeValueAsString(execution.trigger) map.notifications = mapper.writeValueAsString(execution.notifications) + map.receivedArtifacts = mapper.writeValueAsString(execution.receivedArtifacts) map.initialConfig = mapper.writeValueAsString(execution.initialConfig) } else if (execution instanceof Orchestration) { map.description = execution.description @@ -653,6 +654,7 @@ class JedisExecutionRepository implements ExecutionRepository { execution.pipelineConfigId = map.pipelineConfigId execution.trigger.putAll(mapper.readValue(map.trigger, Map)) execution.notifications.addAll(mapper.readValue(map.notifications, List)) + execution.receivedArtifacts.addAll(mapper.readValue(map.receivedArtifacts, List)) execution.initialConfig.putAll(mapper.readValue(map.initialConfig, Map)) } else if (execution instanceof Orchestration) { execution.description = map.description