com.netflix.spinnaker.orca.pipeline.model.Stage.ancestors()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(99)

本文整理了Java中com.netflix.spinnaker.orca.pipeline.model.Stage.ancestors()方法的一些代码示例,展示了Stage.ancestors()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Stage.ancestors()方法的具体详情如下:
包路径:com.netflix.spinnaker.orca.pipeline.model.Stage
类名称:Stage
方法名:ancestors

Stage.ancestors介绍

[英]Gets all ancestor stages, including the current stage.
[中]获取所有祖先阶段,包括当前阶段。

代码示例

代码示例来源:origin: com.netflix.spinnaker.orca/orca-core

/**
 * As per `Stage.ancestors` except this method returns tuples of the stages
 * and their `StageDefinitionBuilder`.
 */
public List<Result> ancestors(Stage startingStage) {
 return startingStage
  .ancestors()
  .stream()
  .map(it ->
   new Result(it, stageDefinitionBuilders.get(it.getType()))
  )
  .collect(toList());
}

代码示例来源:origin: com.netflix.spinnaker.orca/orca-core

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();
}

代码示例来源:origin: com.netflix.spinnaker.orca/orca-core

@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);
 }
}

代码示例来源:origin: com.netflix.spinnaker.orca/orca-core

@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;
 }
}

代码示例来源:origin: com.netflix.spinnaker.orca/orca-clouddriver

@VisibleForTesting
Collection<String> upstreamImageIds(Stage sourceStage, Collection<String> consideredStageRefIds, String cloudProviderType) {
 List<Stage> ancestors = sourceStage.ancestors();
 List<Stage> imageProvidingAncestorStages = ancestors.stream()
  .filter(stage -> {
   String cloudProvider = (String) stage.getContext().getOrDefault("cloudProvider", stage.getContext().get("cloudProviderType"));
   boolean consideredStageRefIdMatches = consideredStageRefIds == null || consideredStageRefIds.isEmpty() || consideredStageRefIds.contains(stage.getRefId()) || (stage.getParent() != null && consideredStageRefIds.contains(stage.getParent().getRefId()));
   return consideredStageRefIdMatches && (stage.getContext().containsKey("imageId") || stage.getContext().containsKey("amiDetails")) && cloudProviderType.equals(cloudProvider);
  }).collect(toList());
 return imageProvidingAncestorStages.stream().map(it -> {
  if (it.getContext().containsKey("imageId")) {
   return (String) it.getContext().get("imageId");
  } else {
   return (String) ((List<Map>) it.getContext().get("amiDetails")).get(0).get("imageId");
  }
 }).collect(toList());
}

相关文章