Skip to content

Commit

Permalink
fix(provider/kubernetes): guard against empty api & kind (#2472)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwander authored Mar 30, 2018
1 parent e06601d commit b87021e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -55,6 +56,10 @@ public String toString() {

@JsonCreator
public static KubernetesApiVersion fromString(String name) {
if (StringUtils.isEmpty(name)) {
return null;
}

Optional<KubernetesApiVersion> versionOptional = values.stream()
.filter(v -> v.name.equalsIgnoreCase(name))
.findAny();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -91,6 +92,10 @@ public String toString() {

@JsonCreator
public static KubernetesKind fromString(String name) {
if (StringUtils.isEmpty(name)) {
return null;
}

Optional<KubernetesKind> kindOptional = values.stream()
.filter(v -> v.name.equalsIgnoreCase(name) || (v.alias != null && v.alias.equalsIgnoreCase(name)))
.findAny();
Expand Down

0 comments on commit b87021e

Please sign in to comment.