Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Implement custom schema for config.affinity.nodeSelector #752

Merged
merged 14 commits into from
Mar 26, 2024
Merged
5 changes: 5 additions & 0 deletions crates/stackable-operator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ All notable changes to this project will be documented in this file.

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

## Fixed

- Fix wrong schema (and thus CRD) for `config.affinity.nodeSelector` ([#752]).

[#752]: https://github.com/stackabletech/operator-rs/pull/752
[#757]: https://github.com/stackabletech/operator-rs/pull/757

## [0.65.0] - 2024-03-25
Expand Down
10 changes: 10 additions & 0 deletions crates/stackable-operator/src/commons/affinity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,18 @@ pub struct StackableAffinity {
pub node_selector: Option<StackableNodeSelector>,
}

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