Skip to content

Commit cf5aa2f

Browse files
committed
chore: Add dev comments
1 parent fc4aef4 commit cf5aa2f

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

  • crates/stackable-operator/src/crd/scaler

crates/stackable-operator/src/crd/scaler/mod.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ pub struct ScalerStatus {
5959
pub last_transition_time: Time,
6060
}
6161

62+
// We use `#[serde(tag)]` and `#[serde(content)]` here to circumvent Kubernetes restrictions in their
63+
// structural schema subset of OpenAPI schemas. They don't allow one variant to be typed as a string
64+
// and others to be typed as objects. We therefore encode the variant data in a separate details
65+
// key/object. With this, all variants can be encoded as strings, while the status can still contain
66+
// additional data in an extra field when needed.
6267
#[derive(Clone, Debug, Deserialize, Serialize, strum::Display)]
6368
#[serde(
6469
tag = "state",
@@ -99,6 +104,10 @@ pub enum ScalerState {
99104
},
100105
}
101106

107+
// We manually implement the JSON schema instead of deriving it, because kube's schema transformer
108+
// cannot handle the derived JsonSchema and proceeds to hit the following error: "Property "state"
109+
// has the schema ... but was already defined as ... in another subschema. The schemas for a
110+
// property used in multiple subschemas must be identical".
102111
impl JsonSchema for ScalerState {
103112
fn schema_name() -> Cow<'static, str> {
104113
"ScalerState".into()
@@ -130,7 +139,7 @@ impl JsonSchema for ScalerState {
130139
}
131140
}
132141

133-
/// Which stage of a scaling operation failed.
142+
/// In which state the scaling operation failed.
134143
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
135144
#[serde(rename_all = "camelCase")]
136145
pub enum FailedInState {

0 commit comments

Comments
 (0)