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(artifacts): Add receivedArtifacts to Pipeline model. #1648

Merged
merged 1 commit into from
Sep 27, 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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions orca-core/orca-core.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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> {

Expand Down Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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> {

Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down