Skip to content

Commit 8fb008a

Browse files
authored
fix(versioned)!: Replace yaml_serde with serde_json to track changed values (#1307)
* fix(versioned)!: Replace yaml_serde with serde_json to track changed values This fixes #1301 * chore(versioned): Add changelog entries
1 parent b977e0e commit 8fb008a

13 files changed

Lines changed: 105 additions & 91 deletions

‎Cargo.lock‎

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/stackable-versioned-macros/src/codegen/item/field.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ impl VersionedField {
315315
Direction::Downgrade => {
316316
let next_change = changes.get_expect(&next_version.inner);
317317

318-
let yaml_serde_path = &*mod_gen_ctx.crates.yaml_serde;
318+
let serde_json_path = &*mod_gen_ctx.crates.serde_json;
319319
let versioned_path = &*mod_gen_ctx.crates.versioned;
320320

321321
match next_change {
@@ -327,7 +327,7 @@ impl VersionedField {
327327
Some(quote! {
328328
upgrades.push(#versioned_path::ChangedValue {
329329
json_path: #json_path_ident,
330-
value: #yaml_serde_path::to_value(&#from_struct_ident.#ident).unwrap(),
330+
value: #serde_json_path::to_value(&#from_struct_ident.#ident).unwrap(),
331331
});
332332
})
333333
}
@@ -349,7 +349,7 @@ impl VersionedField {
349349
// for applying a tracked value.
350350
let changes = self.changes.as_ref()?;
351351

352-
let yaml_serde_path = &*mod_gen_ctx.crates.yaml_serde;
352+
let serde_json_path = &*mod_gen_ctx.crates.serde_json;
353353
let versioned_path = &*mod_gen_ctx.crates.versioned;
354354

355355
match direction {
@@ -368,7 +368,7 @@ impl VersionedField {
368368
Some(quote! {
369369
if let Some(#versioned_path::ChangedValue { value, .. }) = upgrades.extract_first_if(|u| u.json_path == #json_path_ident) {
370370
// TODO (@Techassi): Switch to serde_json
371-
spec.#ident = #yaml_serde_path::from_value(value).expect(#expect_message);
371+
spec.#ident = #serde_json_path::from_value(value).expect(#expect_message);
372372
}
373373
})
374374
}

‎crates/stackable-versioned-macros/tests/snapshots/stackable_versioned_macros__snapshots__pass@conversion_tracking.rs.snap‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/stackable-versioned-macros/tests/snapshots/stackable_versioned_macros__snapshots__pass@conversion_tracking_enum.rs.snap‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/stackable-versioned-macros/tests/snapshots/stackable_versioned_macros__snapshots__pass@conversion_tracking_generics.rs.snap‎

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/stackable-versioned-macros/tests/snapshots/stackable_versioned_macros__snapshots__pass@conversion_tracking_hints.rs.snap‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/stackable-versioned-macros/tests/snapshots/stackable_versioned_macros__snapshots__pass@docs.rs.snap‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/stackable-versioned/CHANGELOG.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,19 @@ All notable changes to this project will be documented in this file.
99
- Add public `ExtractIfExt` trait ([#13006]).
1010
- Re-add support for generics in tracking impls ([#1304]).
1111

12+
### Changed
13+
14+
- BREAKING: `stackable_versioned::ChangedValue`'s `value` field type is now `serde_json::Value` instead
15+
of `yaml_serde::Value` ([#1307]).
16+
1217
### Fixed
1318

19+
- Fix how the generated code (de)serializes enums in the tracking status ([#1307]).
1420
- Correctly handle tracked per-version changes across multiple containers ([#1306]).
1521

1622
[#1304]: https://github.com/stackabletech/operator-rs/pull/1304
1723
[#1306]: https://github.com/stackabletech/operator-rs/pull/1306
24+
[#1307]: https://github.com/stackabletech/operator-rs/pull/1307
1825

1926
## [0.13.0] - 2026-10-14
2027

‎crates/stackable-versioned/Cargo.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ kube.workspace = true
1717
schemars.workspace = true
1818
serde.workspace = true
1919
serde_json.workspace = true
20-
yaml_serde.workspace = true
2120
snafu.workspace = true
2221

2322
[dev-dependencies]

‎crates/stackable-versioned/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub struct ChangedValue {
114114

115115
/// The value to be used when upgrading or downgrading the custom resource.
116116
#[schemars(schema_with = "raw_object_schema")]
117-
pub value: yaml_serde::Value,
117+
pub value: serde_json::Value,
118118
}
119119

120120
// TODO (@Techassi): Think about where this should live. Basically this already exists in

0 commit comments

Comments
 (0)