Skip to content

Commit

Permalink
fix(manifest): Fix deployment of artifact only stages (#4044) (#4052)
Browse files Browse the repository at this point in the history
Co-authored-by: Justin Field <justin.field@armory.io>
(cherry picked from commit d5614ea)

Co-authored-by: Gavin Bunney <409207+gavinbunney@users.noreply.github.com>
  • Loading branch information
mergify[bot] and gavinbunney authored Jan 27, 2021
1 parent 5966959 commit b5b53f5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ private ImmutableMap<String, Object> getOutputs(ManifestEvaluator.Result result)
// Spel is not flattening nested List anymore
// We flatten them because its possible have a List of manifests resolved by spel
private List<Object> flattenNestedLists(Object manifests) {
if (manifests == null) {
return null;
}

List<Object> result = new ArrayList<>();
List<Object> tmp = (List<Object>) manifests;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,31 @@ void manifestsWithListsIsFlattened() {
assertThat(getManifests(result)).containsExactly(MANIFEST_1, MANIFEST_2);
}

@Test
void stageWithoutManifestsHandled() {
ManifestEvaluator manifestEvaluator = mock(ManifestEvaluator.class);
ResolveDeploySourceManifestTask task = new ResolveDeploySourceManifestTask(manifestEvaluator);

StageExecutionImpl myStage = createStageWithManifests(null);

DeployManifestContext deployManifestContext = DeployManifestContext.builder().build();

when(manifestEvaluator.evaluate(any(), eq(deployManifestContext)))
.thenReturn(
new ManifestEvaluator.Result(
ImmutableList.of(MANIFEST_1), ImmutableList.of(), ImmutableList.of()));

TaskResult result = task.execute(myStage);
verify(manifestEvaluator, times(1)).evaluate(any(), eq(deployManifestContext));
}

private StageExecutionImpl createStageWithManifests(ImmutableList<Object> manifestsByNamespace) {
return new StageExecutionImpl(
new PipelineExecutionImpl(ExecutionType.PIPELINE, "test"),
"test",
new HashMap<>(ImmutableMap.of("manifests", manifestsByNamespace)));
manifestsByNamespace != null
? new HashMap<>(ImmutableMap.of("manifests", manifestsByNamespace))
: new HashMap<>());
}

private static List<Map<Object, Object>> getManifests(TaskResult result) {
Expand Down

0 comments on commit b5b53f5

Please sign in to comment.