|
12 | 12 | //! See [`versioned`] for an in-depth usage guide and a list of supported |
13 | 13 | //! parameters. |
14 | 14 |
|
15 | | -use std::collections::HashMap; |
16 | | - |
17 | | -use k8s_version::Version; |
18 | | -use schemars::schema::{InstanceType, Schema, SchemaObject, SingleOrVec}; |
19 | 15 | // Re-export macro |
20 | | -pub use stackable_versioned_macros::*; |
21 | | - |
22 | | -// NOTE (@Techassi): This struct represents a rough first draft of how tracking values across |
23 | | -// CRD versions can be achieved. It is currently untested and unproven and might change down the |
24 | | -// line. Currently, this struct is only generated by the macro but not actually used by any other |
25 | | -// code. The tracking itself will be introduced in a follow-up PR. |
26 | | -#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)] |
27 | | -pub struct ChangedValues { |
28 | | - /// List of values needed when downgrading to a particular version. |
29 | | - pub downgrades: HashMap<Version, Vec<ChangedValue>>, |
30 | | - |
31 | | - /// List of values needed when upgrading to a particular version. |
32 | | - pub upgrades: HashMap<Version, Vec<ChangedValue>>, |
33 | | -} |
34 | | - |
35 | | -#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)] |
36 | | -pub struct ChangedValue { |
37 | | - /// The name of the field of the custom resource this value is for. |
38 | | - pub name: String, |
39 | | - |
40 | | - /// The value to be used when upgrading or downgrading the custom resource. |
41 | | - #[schemars(schema_with = "raw_object_schema")] |
42 | | - pub value: serde_yaml::Value, |
43 | | -} |
| 16 | +#[cfg(feature = "k8s")] |
| 17 | +pub use k8s::*; |
| 18 | +pub use stackable_versioned_macros::versioned; |
44 | 19 |
|
45 | | -// TODO (@Techassi): Think about where this should live. Basically this already exists in |
46 | | -// stackable-operator, but we cannot use it without depending on it which I would like to |
47 | | -// avoid. |
48 | | -fn raw_object_schema(_: &mut schemars::r#gen::SchemaGenerator) -> Schema { |
49 | | - Schema::Object(SchemaObject { |
50 | | - instance_type: Some(SingleOrVec::Single(Box::new(InstanceType::Object))), |
51 | | - extensions: [( |
52 | | - "x-kubernetes-preserve-unknown-fields".to_owned(), |
53 | | - serde_json::Value::Bool(true), |
54 | | - )] |
55 | | - .into(), |
56 | | - ..Default::default() |
57 | | - }) |
58 | | -} |
| 20 | +#[cfg(feature = "k8s")] |
| 21 | +mod k8s; |
0 commit comments