From 04fe8187930b630683a56b80847f56424070e0de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Teo=20Klestrup=20R=C3=B6ijezon?= Date: Fri, 14 Oct 2022 10:43:09 +0200 Subject: [PATCH] Fix compatibility with schemars' preserve_order feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #1049 Signed-off-by: Teo Klestrup Röijezon --- kube-core/src/schema.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kube-core/src/schema.rs b/kube-core/src/schema.rs index 241578fb9..1b1675506 100644 --- a/kube-core/src/schema.rs +++ b/kube-core/src/schema.rs @@ -2,14 +2,13 @@ //! //! [`CustomResourceDefinition`]: `k8s_openapi::apiextensions_apiserver::pkg::apis::apiextensions::v1::CustomResourceDefinition` -use std::collections::btree_map::Entry; - // Used in docs #[allow(unused_imports)] use schemars::gen::SchemaSettings; use schemars::{ schema::{InstanceType, Metadata, ObjectValidation, Schema, SchemaObject, SingleOrVec}, visit::Visitor, + MapEntry, }; /// schemars [`Visitor`] that rewrites a [`Schema`] to conform to Kubernetes' "structural schema" rules @@ -101,10 +100,10 @@ fn hoist_subschema_properties( let variant_properties = std::mem::take(&mut variant_obj.properties); for (property_name, property) in variant_properties { match common_obj.properties.entry(property_name) { - Entry::Vacant(entry) => { + MapEntry::Vacant(entry) => { entry.insert(property); } - Entry::Occupied(entry) => { + MapEntry::Occupied(entry) => { if &property != entry.get() { 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", entry.key(),