Skip to content

Commit

Permalink
fix(json): look in older places for execution context too (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Graff committed Apr 10, 2018
1 parent f704192 commit 2fe632b
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,18 @@ public CanaryExecutionStatusResponse fromExecution(String unresolvedStorageAccou
return canaryExecutionStatusResponseBuilder.build();
}

// Some older (stored) results have the execution request only in the judge context.
public String getCanaryExectutionRequestFromJudgeContext(Execution pipeline) {
Stage contextStage = pipeline.getStages().stream()
.filter(stage -> stage.getRefId().equals(CanaryStageNames.REFID_JUDGE))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("Unable to find stage '" + CanaryStageNames.REFID_JUDGE + "' in pipeline ID '" + pipeline.getId() + "'"));
Map<String, Object> context = contextStage.getContext();

return (String) context.get("canaryExecutionRequest");
}


public CanaryExecutionRequest getCanaryExecutionRequest(Execution pipeline) {
Stage contextStage = pipeline.getStages().stream()
.filter(stage -> stage.getRefId().equals(CanaryStageNames.REFID_SET_CONTEXT))
Expand All @@ -211,6 +223,9 @@ public CanaryExecutionRequest getCanaryExecutionRequest(Execution pipeline) {
Map<String, Object> context = contextStage.getContext();

String canaryExecutionRequestJSON = (String)context.get("canaryExecutionRequest");
if (canaryExecutionRequestJSON == null) {
canaryExecutionRequestJSON = getCanaryExectutionRequestFromJudgeContext(pipeline);
}
if (canaryExecutionRequestJSON == null) {
return null;
}
Expand Down

0 comments on commit 2fe632b

Please sign in to comment.