private static String resolveMetricSetListId(Stage stage) { Map<String, Object> outputs = stage.getOutputs(); String metricSetListId = (String)outputs.get("metricSetListId"); // TODO(duftler): Remove this once the risk of operating on out-of-date pipelines is low. if (StringUtils.isEmpty(metricSetListId)) { // Fallback to the older key name. metricSetListId = (String)outputs.get("metricSetId"); } return metricSetListId; } }
.findFirst() .orElseThrow(() -> new IllegalArgumentException("Unable to find stage 'compareJudgeResults' in pipeline ID '" + canaryExecutionId + "'")); Map<String, Object> compareJudgeResultsOutputs = compareJudgeResultsStage.getOutputs(); Boolean isComplete = pipeline.getStatus().isComplete(); String pipelineStatus = pipeline.getStatus().toString().toLowerCase();
.findFirst() .orElseThrow(() -> new IllegalArgumentException("Unable to find stage '" + CanaryStageNames.REFID_JUDGE + "' in pipeline ID '" + canaryExecutionId + "'")); Map<String, Object> judgeOutputs = judgeStage.getOutputs(); .orElseThrow(() -> new IllegalArgumentException("Unable to find stage '" + CanaryStageNames.REFID_MIX_METRICS + "' in pipeline ID '" + canaryExecutionId + "'")); Map<String, Object> mixerContext = mixerStage.getContext(); Map<String, Object> mixerOutputs = mixerStage.getOutputs();
.findFirst() .ifPresent(generateCanaryAnalysisResultStage -> Optional .ofNullable(generateCanaryAnalysisResultStage.getOutputs() .getOrDefault(CANARY_ANALYSIS_EXECUTION_RESULT, null)) .ifPresent(data -> responseBuilder.canaryAnalysisExecutionResult(kayentaObjectMapper.convertValue(data,
private static String resolveMetricSetListId(Stage stage) { Map<String, Object> outputs = stage.getOutputs(); String metricSetListId = (String)outputs.get("metricSetListId"); // TODO(duftler): Remove this once the risk of operating on out-of-date pipelines is low. if (StringUtils.isEmpty(metricSetListId)) { // Fallback to the older key name. metricSetListId = (String)outputs.get("metricSetId"); } return metricSetListId; } }
private static Map<String, Object> findBuildInfoInUpstreamStage(Stage currentStage, List<Pattern> packageFilePatterns) { Stage upstreamStage = currentStage .ancestors() .stream() .filter(it -> { Map<String, Object> buildInfo = (Map<String, Object>) it.getOutputs().get("buildInfo"); return buildInfo != null && artifactMatch((List<Map<String, String>>) buildInfo.get("artifacts"), packageFilePatterns); }) .findFirst() .orElse(null); return upstreamStage != null ? (Map<String, Object>) upstreamStage.getOutputs().get("buildInfo") : emptyMap(); }
@Override public Object get(@Nullable Object key) { if (delegate().containsKey(key)) { return super.get(key); } else { return stage .ancestors() .stream() .filter(it -> it.getOutputs().containsKey(key)) .findFirst() .map(it -> it.getOutputs().get(key)) .orElse(null); } }
public @Nonnull List<Artifact> getAllArtifacts(@Nonnull Execution execution) { // Get all artifacts emitted by the execution's stages; we'll sort the stages topologically, // then reverse the result so that artifacts from later stages will appear // earlier in the results. List<Artifact> emittedArtifacts = Stage.topologicalSort(execution.getStages()) .filter(s -> s.getOutputs().containsKey("artifacts")) .flatMap( s -> (Stream<Artifact>) ((List) s.getOutputs().get("artifacts")) .stream() .map(a -> a instanceof Map ? objectMapper.convertValue(a, Artifact.class) : a) ).collect(Collectors.toList()); Collections.reverse(emittedArtifacts); // Get all artifacts in the parent pipeline's trigger; these artifacts go at the end of the list, // after any that were emitted by the pipeline List<Artifact> triggerArtifacts = objectMapper.convertValue(execution.getTrigger().getArtifacts(), new TypeReference<List<Artifact>>() {}); emittedArtifacts.addAll(triggerArtifacts); return emittedArtifacts; }
@SuppressWarnings("unchecked") public <E> List<E> getAll(Object key) { List<E> result = (List<E>) stage .ancestors() .stream() .filter(it -> it.getOutputs().containsKey(key)) .map(it -> it.getOutputs().get(key)) .collect(toList()); if (delegate.containsKey(key)) { result.add(0, (E) delegate.get(key)); } if (key.equals("artifacts")) { result.add((E) getTrigger().getArtifacts()); } else if (key.equals("resolvedExpectedArtifacts")) { result.add((E) getTrigger().getResolvedExpectedArtifacts()); } return result; } }
.findFirst() .orElseThrow(() -> new IllegalArgumentException("Unable to find stage 'compareJudgeResults' in pipeline ID '" + canaryExecutionId + "'")); Map<String, Object> compareJudgeResultsOutputs = compareJudgeResultsStage.getOutputs(); Boolean isComplete = pipeline.getStatus().isComplete(); String pipelineStatus = pipeline.getStatus().toString().toLowerCase();
try { map.put(prefix + "context", mapper.writeValueAsString(stage.getContext())); map.put(prefix + "outputs", mapper.writeValueAsString(stage.getOutputs())); map.put(prefix + "tasks", mapper.writeValueAsString(stage.getTasks())); map.put(prefix + "lastModified", (stage.getLastModified() != null ? mapper.writeValueAsString(stage.getLastModified()) : null));
@Override public TaskResult execute(@Nonnull Stage stage) { DeleteImageStage.DeleteImageRequest deleteImageRequest = stage.mapTo(DeleteImageStage.DeleteImageRequest.class); List<String> deleteResult = (List<String>) Optional.ofNullable(stage.getOutputs().get("delete.image.ids")) .orElse(new ArrayList<>());
StageData stageData = parent.mapTo(StageData.class); Map<String, Object> parentOutputs = parent.getOutputs(); Map<String, String> rollbackTypes = (Map<String, String>) parentOutputs.get("rollbackTypes"); Map<String, Map<String, Object>> rollbackContexts = (Map<String, Map<String, Object>>) parentOutputs.get("rollbackContexts"); context.put( "rollbackType", ((Map) parent.getOutputs().get("rollbackTypes")).get(region) );
.findFirst() .orElseThrow(() -> new IllegalArgumentException("Unable to find stage '" + CanaryStageNames.REFID_JUDGE + "' in pipeline ID '" + canaryExecutionId + "'")); Map<String, Object> judgeOutputs = judgeStage.getOutputs(); .orElseThrow(() -> new IllegalArgumentException("Unable to find stage '" + CanaryStageNames.REFID_MIX_METRICS + "' in pipeline ID '" + canaryExecutionId + "'")); Map<String, Object> mixerContext = mixerStage.getContext(); Map<String, Object> mixerOutputs = mixerStage.getOutputs();
.findFirst() .ifPresent(generateCanaryAnalysisResultStage -> Optional .ofNullable(generateCanaryAnalysisResultStage.getOutputs() .getOrDefault(CANARY_ANALYSIS_EXECUTION_RESULT, null)) .ifPresent(data -> responseBuilder.canaryAnalysisExecutionResult(kayentaObjectMapper.convertValue(data,