From 0bae359058d6105b65441391df3338e51657a74b Mon Sep 17 00:00:00 2001 From: Steven Hawkins Date: Fri, 22 Sep 2023 12:29:29 -0400 Subject: [PATCH] narrows condition status to a string (#22439) Closes #21299 --- .../crds/v2alpha1/StatusCondition.java | 33 +++++-------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/operator/src/main/java/org/keycloak/operator/crds/v2alpha1/StatusCondition.java b/operator/src/main/java/org/keycloak/operator/crds/v2alpha1/StatusCondition.java index 2033256785..b366bddb86 100644 --- a/operator/src/main/java/org/keycloak/operator/crds/v2alpha1/StatusCondition.java +++ b/operator/src/main/java/org/keycloak/operator/crds/v2alpha1/StatusCondition.java @@ -17,15 +17,11 @@ package org.keycloak.operator.crds.v2alpha1; -import io.fabric8.kubernetes.api.model.AnyType; - import java.util.Objects; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.TextNode; /** * @author Vaclav Muzikar @@ -39,7 +35,7 @@ public class StatusCondition { } private String type; - private JsonNode status = TextNode.valueOf(Status.Unknown.name()); + private String status = Status.Unknown.name(); private String message; private String lastTransitionTime; private Long observedGeneration; @@ -54,43 +50,30 @@ public class StatusCondition { @JsonIgnore public Boolean getStatus() { - if (status == null || status.isNull()) { - return null; - } - // account for the legacy boolean string as well - switch (status.asText()) { - case "false": - case "False": - return false; - case "true": - case "True": - return true; - default: + if (status == null || Status.Unknown.name().equals(status)) { return null; } + return Status.True.name().equals(status); } @JsonProperty("status") public String getStatusString() { - if (status == null || status.isNull()) { - return null; - } - return status.asText(); + return status; } @JsonProperty("status") public void setStatusString(String status) { - this.status = TextNode.valueOf(status); + this.status = status; } @JsonIgnore public void setStatus(Boolean status) { if (status == null) { - this.status = TextNode.valueOf(Status.Unknown.name()); + this.status = Status.Unknown.name(); } else if (status) { - this.status = TextNode.valueOf(Status.True.name()); + this.status = Status.True.name(); } else { - this.status = TextNode.valueOf(Status.False.name()); + this.status = Status.False.name(); } }