77
88use std:: collections:: { BTreeMap , HashMap } ;
99
10- use schemars:: { JsonSchema , Schema , json_schema } ;
10+ use schemars:: JsonSchema ;
1111use serde:: { Deserialize , Serialize } ;
1212use snafu:: { ResultExt , Snafu } ;
1313
14- /// Generates a JSON schema that accepts any JSON value.
15- ///
16- /// Kubernetes CRDs do not support the `true` schema shorthand that
17- /// `serde_json::Value` generates by default. Instead we emit a schema
18- /// with `x-kubernetes-preserve-unknown-fields: true` which tells the
19- /// API server to store the value as-is.
20- fn arbitrary_json_value ( _gen : & mut schemars:: generate:: SchemaGenerator ) -> Schema {
21- json_schema ! ( {
22- "x-kubernetes-preserve-unknown-fields" : true ,
23- } )
24- }
25-
26- /// Generates a JSON schema for a list of JSON patch operation strings (RFC 6902).
27- fn json_patch_string_list ( _gen : & mut schemars:: generate:: SchemaGenerator ) -> Schema {
28- json_schema ! ( {
29- "type" : "array" ,
30- "items" : {
31- "type" : "string" ,
32- } ,
33- } )
34- }
14+ use crate :: utils:: crds:: raw_object_schema;
3515
3616#[ derive( Debug , Snafu ) ]
3717pub enum Error {
@@ -107,7 +87,7 @@ impl KeyValueConfigOverrides {
10787pub enum JsonConfigOverrides {
10888 /// Can be set to arbitrary YAML content, which is converted to JSON and used as
10989 /// [RFC 7396](https://datatracker.ietf.org/doc/html/rfc7396) JSON merge patch.
110- #[ schemars( schema_with = "arbitrary_json_value " ) ]
90+ #[ schemars( schema_with = "raw_object_schema " ) ]
11191 JsonMergePatch ( serde_json:: Value ) ,
11292
11393 /// List of [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902) JSON patches.
@@ -122,7 +102,6 @@ pub enum JsonConfigOverrides {
122102 /// or
123103 ///
124104 /// `{"op": "add", "path": "/0/happy", "value": true}`
125- #[ schemars( schema_with = "json_patch_string_list" ) ]
126105 JsonPatches ( Vec < String > ) ,
127106
128107 /// Override the entire config file with the specified String.
0 commit comments