public CanaryExecutionRequest getCanaryExecutionRequest(Execution pipeline) { Stage contextStage = pipeline.getStages().stream() .filter(stage -> stage.getRefId().equals(CanaryStageNames.REFID_SET_CONTEXT)) .findFirst() .orElseThrow(() -> new IllegalArgumentException("Unable to find stage '" + CanaryStageNames.REFID_SET_CONTEXT + "' in pipeline ID '" + pipeline.getId() + "'")); Map<String, Object> context = contextStage.getContext(); String canaryExecutionRequestJSON = (String)context.get("canaryExecutionRequest"); if (canaryExecutionRequestJSON == null) { canaryExecutionRequestJSON = getCanaryExecutionRequestFromJudgeContext(pipeline); } if (canaryExecutionRequestJSON == null) { return null; } CanaryExecutionRequest canaryExecutionRequest = null; try { canaryExecutionRequest = objectMapper.readValue(canaryExecutionRequestJSON, CanaryExecutionRequest.class); } catch (IOException e) { log.error("Cannot deserialize canaryExecutionRequest", e); throw new IllegalArgumentException("Cannot deserialize canaryExecutionRequest", e); } return canaryExecutionRequest; }
public CanaryExecutionRequest getCanaryExecutionRequest(Execution pipeline) { Stage contextStage = pipeline.getStages().stream() .filter(stage -> stage.getRefId().equals(CanaryStageNames.REFID_SET_CONTEXT)) .findFirst() .orElseThrow(() -> new IllegalArgumentException("Unable to find stage '" + CanaryStageNames.REFID_SET_CONTEXT + "' in pipeline ID '" + pipeline.getId() + "'")); Map<String, Object> context = contextStage.getContext(); String canaryExecutionRequestJSON = (String)context.get("canaryExecutionRequest"); if (canaryExecutionRequestJSON == null) { canaryExecutionRequestJSON = getCanaryExecutionRequestFromJudgeContext(pipeline); } if (canaryExecutionRequestJSON == null) { return null; } CanaryExecutionRequest canaryExecutionRequest = null; try { canaryExecutionRequest = objectMapper.readValue(canaryExecutionRequestJSON, CanaryExecutionRequest.class); } catch (IOException e) { log.error("Cannot deserialize canaryExecutionRequest", e); throw new IllegalArgumentException("Cannot deserialize canaryExecutionRequest", e); } return canaryExecutionRequest; }