Skip to content

Commit

Permalink
fix(kubernetes): do not throw NPE on NetworkPolicies with null ingres…
Browse files Browse the repository at this point in the history
…s and egress (#4172) (#4173)
  • Loading branch information
spinnakerbot authored and Travis Tomsu committed Nov 25, 2019
1 parent abad479 commit d9bedbf
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,19 @@ public static KubernetesV2SecurityGroup fromCacheData(CacheData cd) {
}

private static Set<Rule> inboundRules(V1NetworkPolicy policy) {
if (policy.getSpec().getIngress() == null) {
return Collections.emptySet();
}
return policy.getSpec().getIngress().stream()
.map(i -> i.getPorts().stream().map(KubernetesV2SecurityGroup::fromPolicyPort))
.flatMap(s -> s)
.collect(Collectors.toSet());
}

private static Set<Rule> outboundRules(V1NetworkPolicy policy) {
if (policy.getSpec().getEgress() == null) {
return Collections.emptySet();
}
return policy.getSpec().getEgress().stream()
.map(i -> i.getPorts().stream().map(KubernetesV2SecurityGroup::fromPolicyPort))
.flatMap(s -> s)
Expand Down

0 comments on commit d9bedbf

Please sign in to comment.