Skip to content

Commit

Permalink
feat(stage context): Get all stage results in a list
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars Wander committed Sep 29, 2017
1 parent 8d8dc93 commit cda9bae
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@

package com.netflix.spinnaker.orca.pipeline.model;

import com.google.common.collect.ForwardingMap;

import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Nullable;
import com.google.common.collect.ForwardingMap;
import java.util.stream.Collectors;

public class StageContext extends ForwardingMap<String, Object> {

Expand Down Expand Up @@ -53,4 +56,16 @@ public StageContext(Stage<?> stage) {
);
}
}

/*
* Gets all objects matching 'key', sorted by proximity to the current stage
*/
public List<Object> getAll(Object key) {
return stage
.ancestors()
.stream()
.filter(it -> it.getOutputs().containsKey(key))
.map(it -> it.getOutputs().get(key))
.collect(Collectors.toList());
}
}

0 comments on commit cda9bae

Please sign in to comment.