Skip to content

Commit

Permalink
Fix stage resolver (spinnaker#3575)
Browse files Browse the repository at this point in the history
* fix(plugins): Stage resolver requires alias to be passed in if present on the stage context to resolve builders

* fix(plugins): Stage resolver requires alias to be passed in if present on the stage context to resolve builders
  • Loading branch information
srekapalli authored Apr 5, 2020
1 parent 26607ff commit d517d59
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public StageDefinitionBuilder getStageDefinitionBuilder(@Nonnull String type, St
type, stageDefinitionBuilderByAlias.get(typeAlias));

if (stageDefinitionBuilder == null) {
throw new NoSuchStageDefinitionBuilderException(type, stageDefinitionBuilderByAlias.keySet());
throw new NoSuchStageDefinitionBuilderException(
type, typeAlias, stageDefinitionBuilderByAlias.keySet());
}

return stageDefinitionBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class DynamicStageResolver(
}

if (builder == null) {
throw StageResolver.NoSuchStageDefinitionBuilderException(type, stageDefinitionBuildersByAlias.keys)
throw StageResolver.NoSuchStageDefinitionBuilderException(type, typeAlias, stageDefinitionBuildersByAlias.keys)
}

return builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ class DuplicateStageAliasException extends IllegalStateException {
}

class NoSuchStageDefinitionBuilderException extends IllegalArgumentException {
NoSuchStageDefinitionBuilderException(String type, Collection<String> knownTypes) {
NoSuchStageDefinitionBuilderException(
String type, String alias, Collection<String> knownTypes) {
super(
format(
"No StageDefinitionBuilder implementation for %s found (knownTypes: %s)",
type, String.join(",", knownTypes)));
"No StageDefinitionBuilder implementation for %s(alias: %s) found (knownTypes: %s)",
type, alias, String.join(",", knownTypes)));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ public StageNavigator(StageResolver stageResolver) {
*/
public List<Result> ancestors(StageExecution startingStage) {
return startingStage.ancestors().stream()
.map(it -> new Result(it, stageResolver.getStageDefinitionBuilder(it.getType())))
.map(
it ->
new Result(
it,
stageResolver.getStageDefinitionBuilder(
it.getType(), (String) it.getContext().get("alias"))))
.collect(toList());
}

Expand Down

0 comments on commit d517d59

Please sign in to comment.