Skip to content

Commit 7d6ee75

Browse files
committed
Remove allow_if_equal flag
Signed-off-by: Sebastian Bernauer <[email protected]>
1 parent 9840511 commit 7d6ee75

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

kube-core/src/schema.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl Visitor for StructuralSchemaRewriter {
3939
.and_then(|subschemas| subschemas.one_of.as_mut())
4040
{
4141
// Tagged enums are serialized using `one_of`
42-
hoist_subschema_properties(one_of, &mut schema.object, &mut schema.instance_type, false);
42+
hoist_subschema_properties(one_of, &mut schema.object, &mut schema.instance_type);
4343
}
4444

4545
if let Some(any_of) = schema
@@ -48,7 +48,7 @@ impl Visitor for StructuralSchemaRewriter {
4848
.and_then(|subschemas| subschemas.any_of.as_mut())
4949
{
5050
// Untagged enums are serialized using `any_of`
51-
hoist_subschema_properties(any_of, &mut schema.object, &mut schema.instance_type, true);
51+
hoist_subschema_properties(any_of, &mut schema.object, &mut schema.instance_type);
5252
}
5353

5454
// check for maps without with properties (i.e. flattened maps)
@@ -72,7 +72,6 @@ fn hoist_subschema_properties(
7272
subschemas: &mut Vec<Schema>,
7373
common_obj: &mut Option<Box<ObjectValidation>>,
7474
instance_type: &mut Option<SingleOrVec<InstanceType>>,
75-
allow_if_equal: bool,
7675
) {
7776
let common_obj = common_obj.get_or_insert_with(|| Box::new(ObjectValidation::default()));
7877

@@ -106,21 +105,12 @@ fn hoist_subschema_properties(
106105
entry.insert(property);
107106
}
108107
Entry::Occupied(entry) => {
109-
if allow_if_equal {
110-
if &property == entry.get() {
111-
continue;
112-
}
113-
108+
if &property != entry.get() {
114109
panic!("Property {:?} has the schema {:?} but was already defined as {:?} in another subschema. The schemas for a property used in multiple subschemas must be identical",
115-
entry.key(),
116-
&property,
117-
entry.get());
110+
entry.key(),
111+
&property,
112+
entry.get());
118113
}
119-
120-
panic!(
121-
"Property {:?} was already defined in another subschema",
122-
entry.key()
123-
)
124114
}
125115
}
126116
}

0 commit comments

Comments
 (0)