Skip to content

Commit a1a1390

Browse files
sbernauerTechassi
andauthoredMar 26, 2024
fix: Implement custom schema for config.affinity.nodeSelector (#752)
* fix: Fixed wrong schema for `config.affinity.nodeSelector` * changelog * Update CHANGELOG.md Co-authored-by: Techassi <git@techassi.dev> * Add docs on stackable_node_selector_schema * Rename stackable_node_selector_schema -> optional_stackable_node_selector_schema * USe #[schemars(deny_unknown_fields)] * improve wording * typo * changelog * doccomment -> normal comment --------- Co-authored-by: Techassi <git@techassi.dev>
1 parent 6c7ceb5 commit a1a1390

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed
 

‎crates/stackable-operator/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ All notable changes to this project will be documented in this file.
88

99
- Implement `PartialEq` for most _Snafu_ Error enums ([#757]).
1010

11+
## Fixed
12+
13+
- Fix wrong schema (and thus CRD) for `config.affinity.nodeSelector` ([#752]).
14+
15+
[#752]: https://github.com/stackabletech/operator-rs/pull/752
1116
[#757]: https://github.com/stackabletech/operator-rs/pull/757
1217

1318
## [0.65.0] - 2024-03-25

‎crates/stackable-operator/src/commons/affinity.rs

+10
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,18 @@ pub struct StackableAffinity {
4242
pub node_selector: Option<StackableNodeSelector>,
4343
}
4444

45+
// We can not simply use [`BTreeMap<String, String>`] in [`StackableAffinity`], as the fields need to be [`Atomic`].
46+
// We can not mark it as [`Atomic`], as [`crate::config::fragment::FromFragment`] is already implemented for
47+
// [`BTreeMap<String, String>`].
48+
//
49+
// We `#[serde(flatten)]` the contained [`BTreeMap<String, String>`], so `serde_yaml` can deserialize everything as
50+
// expected.
51+
// FIXME: The generated JsonSchema will be wrong, so until https://github.com/GREsau/schemars/issues/259 is fixed, we
52+
// need to use `#[schemars(deny_unknown_fields)]`.
53+
// See https://github.com/stackabletech/operator-rs/pull/752#issuecomment-2017630433 for details.
4554
#[derive(Clone, Debug, Eq, Deserialize, JsonSchema, PartialEq, Serialize)]
4655
#[serde(rename_all = "camelCase")]
56+
#[schemars(deny_unknown_fields)]
4757
pub struct StackableNodeSelector {
4858
#[serde(flatten)]
4959
pub node_selector: BTreeMap<String, String>,

0 commit comments

Comments
 (0)