Skip to content

Commit

Permalink
fix(trigger): orchestrations may have no trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
robfletcher committed Feb 14, 2018
1 parent 9d158e0 commit 147e438
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Expand Up @@ -16,10 +16,6 @@

package com.netflix.spinnaker.orca.pipeline.model;

import java.io.Serializable;
import java.util.*;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonManagedReference;
Expand All @@ -28,6 +24,12 @@
import com.netflix.spinnaker.orca.ExecutionStatus;
import com.netflix.spinnaker.security.AuthenticatedRequest;
import com.netflix.spinnaker.security.User;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.Serializable;
import java.util.*;

import static com.netflix.spinnaker.orca.ExecutionStatus.NOT_STARTED;
import static com.netflix.spinnaker.orca.pipeline.model.Execution.ExecutionType.ORCHESTRATION;
import static com.netflix.spinnaker.orca.pipeline.model.Execution.ExecutionType.PIPELINE;
Expand All @@ -37,6 +39,8 @@

public class Execution implements Serializable {

public static final DefaultTrigger NO_TRIGGER = new DefaultTrigger("none");

public Execution(ExecutionType type, String application) {
this(type, UUID.randomUUID().toString(), application);
}
Expand Down Expand Up @@ -229,7 +233,7 @@ public void setOrigin(@Nullable String origin) {
this.origin = origin;
}

private Trigger trigger = null;
private Trigger trigger = NO_TRIGGER;

public @Nonnull Trigger getTrigger() {
return trigger;
Expand Down
Expand Up @@ -56,6 +56,7 @@
import static com.google.common.collect.Maps.filterValues;
import static com.netflix.spinnaker.orca.pipeline.model.Execution.ExecutionType.ORCHESTRATION;
import static com.netflix.spinnaker.orca.pipeline.model.Execution.ExecutionType.PIPELINE;
import static com.netflix.spinnaker.orca.pipeline.model.Execution.NO_TRIGGER;
import static com.netflix.spinnaker.orca.pipeline.model.SyntheticStageOwner.STAGE_BEFORE;
import static java.lang.String.format;
import static java.lang.System.currentTimeMillis;
Expand Down Expand Up @@ -504,7 +505,7 @@ private Execution retrieveInternal(RedisClientDelegate redisClientDelegate, Exec
}
execution.setKeepWaitingPipelines(Boolean.parseBoolean(map.get("keepWaitingPipelines")));
execution.setOrigin(map.get("origin"));
execution.setTrigger(mapper.readValue(map.get("trigger"), Trigger.class));
execution.setTrigger(map.get("trigger") != null ? mapper.readValue(map.get("trigger"), Trigger.class) : NO_TRIGGER);
} catch (Exception e) {
throw new ExecutionSerializationException("Failed serializing execution json", e);
}
Expand Down

0 comments on commit 147e438

Please sign in to comment.