narrows condition status to a string (#22439)

Closes #21299
This commit is contained in:
Steven Hawkins 2023-09-22 12:29:29 -04:00 committed by GitHub
parent 48a0b3436d
commit 0bae359058
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 <vmuzikar@redhat.com>
@ -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();
}
}