Skip to content

Commit acf3d57

Browse files
committed
refactor: Simplify the getting or defaulting of the parent object
1 parent dcbe17e commit acf3d57

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

kube-core/src/schema/transform_properties.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,13 @@ pub(crate) fn hoist_properties_for_any_of_subschemas(kube_schema: &mut SchemaObj
8383
while let Some((property_name, Schema::Object(property_schema_object))) =
8484
object.properties.pop_first()
8585
{
86+
let parent_object = parent_object
87+
// get the `ObjectValidation`, or an empty one without any properties set
88+
.get_or_insert_default();
89+
8690
// This would check that the variant property (that we want to now hoist)
8791
// is exactly the same as what is already hoisted (in this function).
88-
if let Some(existing_property) = parent_object
89-
// get the `ObjectValidation`, or an empty one without any properties set
90-
.get_or_insert_default()
91-
.properties
92-
.get(&property_name)
93-
{
92+
if let Some(existing_property) = parent_object.properties.get(&property_name) {
9493
// TODO (@NickLarsenNZ): Here we could do another check to see if it only
9594
// differs by description. If the schema property description is not set, then
9695
// we could overwrite it and not panic.
@@ -102,7 +101,6 @@ pub(crate) fn hoist_properties_for_any_of_subschemas(kube_schema: &mut SchemaObj
102101
} else {
103102
// Otherwise, insert the subschema properties into the schema properties
104103
parent_object
105-
.get_or_insert_default()
106104
.properties
107105
.insert(property_name.clone(), Schema::Object(property_schema_object));
108106
}

0 commit comments

Comments
 (0)