Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
Signed-off-by: clux <[email protected]>
  • Loading branch information
clux committed Mar 7, 2024
1 parent c47fe7f commit 841011f
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ fn extract_container(
// recurse through repeated arrays until we find a concrete type (keep track of how deep we went)
let (mut array_type, recurse_level) = array_recurse_for_type(value, stack, key, 1)?;
trace!("got array {} for {} in level {}", array_type, key, recurse_level);
if !cfg.no_condition && key == "conditions" && is_conditions(&value) {
if !cfg.no_condition && key == "conditions" && is_conditions(value) {
array_type = "Vec<k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition>".into();
} else {
array_recurse_level.insert(key.clone(), recurse_level);
Expand Down Expand Up @@ -452,20 +452,18 @@ fn array_recurse_for_type(
// ----------------------------------------------------------------------------
// helpers
fn is_conditions(value: &JSONSchemaProps) -> bool {
if let Some(items) = &value.items {
if let JSONSchemaPropsOrArray::Schema(props) = &items {
if let Some(p) = &props.properties {
let type_ = p.get("type");
let status = p.get("status");
let reason = p.get("reason");
let message = p.get("message");
let ltt = p.get("lastTransitionTime");
return type_.is_some()
&& status.is_some()
&& reason.is_some()
&& message.is_some()
&& ltt.is_some();
}
if let Some(JSONSchemaPropsOrArray::Schema(props)) = &value.items {
if let Some(p) = &props.properties {
let type_ = p.get("type");
let status = p.get("status");
let reason = p.get("reason");
let message = p.get("message");
let ltt = p.get("lastTransitionTime");
return type_.is_some()
&& status.is_some()
&& reason.is_some()
&& message.is_some()
&& ltt.is_some();
}
}
false
Expand Down

0 comments on commit 841011f

Please sign in to comment.