Skip to content

Commit

Permalink
fix(findImageFromTags): don't fail on missing tags (#3002)
Browse files Browse the repository at this point in the history
When `tags` aren't provided by the user, treat it as if the user set them to an empty map
instead of failing with `NullPointerException`
  • Loading branch information
marchello2000 authored Jun 21, 2019
1 parent 6675281 commit ae0060b
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class FindImageFromTagsTask extends AbstractCloudProviderAwareTask implem
@Override
public TaskResult execute(Stage stage) {
String cloudProvider = getCloudProvider(stage);

ImageFinder imageFinder =
imageFinders.stream()
.filter(it -> it.getCloudProvider().equals(cloudProvider))
Expand All @@ -57,6 +58,11 @@ public TaskResult execute(Stage stage) {
"ImageFinder not found for cloudProvider " + cloudProvider));

StageData stageData = (StageData) stage.mapTo(StageData.class);

if (stageData.tags == null) {
stageData.tags = Collections.emptyMap();
}

Collection<ImageFinder.ImageDetails> imageDetails =
imageFinder.byTags(stage, stageData.packageName, stageData.tags);

Expand Down

0 comments on commit ae0060b

Please sign in to comment.