From b122a2a85dfb3248b713051ce4f4cc617dda48e6 Mon Sep 17 00:00:00 2001 From: Techassi Date: Fri, 23 Oct 2026 09:22:46 +0200 Subject: [PATCH 1/4] chore(versioned)!: Rename "from_" to "previous_" --- .../src/attrs/item/mod.rs | 76 +++++++++---------- .../src/attrs/item/variant.rs | 6 +- .../src/codegen/changes.rs | 20 +++-- .../src/codegen/item/field.rs | 18 +++-- .../src/codegen/item/mod.rs | 13 ++-- .../src/codegen/item/variant.rs | 4 +- crates/stackable-versioned-macros/src/lib.rs | 16 ++-- crates/stackable-versioned/README.md | 2 +- 8 files changed, 81 insertions(+), 74 deletions(-) diff --git a/crates/stackable-versioned-macros/src/attrs/item/mod.rs b/crates/stackable-versioned-macros/src/attrs/item/mod.rs index 7b4092f52..ccbf4500b 100644 --- a/crates/stackable-versioned-macros/src/attrs/item/mod.rs +++ b/crates/stackable-versioned-macros/src/attrs/item/mod.rs @@ -223,32 +223,32 @@ impl CommonItemAttributes { let mut errors = Error::accumulator(); for change in &self.changes { - if change.from_name.is_none() - && change.from_type.is_none() - && change.from_docs.is_none() + if change.previous_name.is_none() + && change.previous_type.is_none() + && change.previous_docs.is_none() { errors.push(Error::custom( - "`from_name`, `from_type` and `from_docs` are unset. Is this `changed()` action needed?" + "`previous_name`, `previous_type` and `previous_docs` are unset. Is this `changed()` action needed?" ).with_span(&change.since.span())); } - // This ensures that `from_name` doesn't include the deprecation prefix. - if let Some(from_name) = change.from_name.as_ref() - && from_name.starts_with(item_ident.deprecation_prefix()) + // This ensures that `previous_name` doesn't include the deprecation prefix. + if let Some(previous_name) = change.previous_name.as_ref() + && previous_name.starts_with(item_ident.deprecation_prefix()) { errors.push( Error::custom("the previous name must not start with the deprecation prefix") - .with_span(&from_name.span()), + .with_span(&previous_name.span()), ); } - if change.from_type.is_none() { + if change.previous_type.is_none() { // The upgrade_with argument only makes sense to use when the // type changed if let Some(upgrade_func) = change.upgrade_with.as_ref() { errors.push( Error::custom( - "the `upgrade_with` argument must be used in combination with `from_type`", + "the `upgrade_with` argument must be used in combination with `previous_type`", ) .with_span(&upgrade_func.span()), ); @@ -259,7 +259,7 @@ impl CommonItemAttributes { if let Some(downgrade_func) = change.downgrade_with.as_ref() { errors.push( Error::custom( - "the `downgrade_with` argument must be used in combination with `from_type`", + "the `downgrade_with` argument must be used in combination with `previous_type`", ) .with_span(&downgrade_func.span()), ); @@ -305,7 +305,7 @@ impl CommonItemAttributes { self.changes .iter() .filter_map(|change| { - let docs = change.from_docs.as_deref()?; + let docs = change.previous_docs.as_deref()?; Some((*change.since, docs.into_doc_comments())) }) .collect() @@ -339,7 +339,7 @@ impl CommonItemAttributes { ); for change in self.changes.iter().rev() { - let from_ident = if let Some(from) = change.from_name.as_deref() { + let previous_ident = if let Some(from) = change.previous_name.as_deref() { format_ident!("{from}").into() } else { ident.clone() @@ -347,8 +347,8 @@ impl CommonItemAttributes { // TODO (@Techassi): This is an awful lot of cloning, can we get // rid of it? - let from_ty = change - .from_type + let previous_type = change + .previous_type .as_ref() .map_or_else(|| ty.clone(), |sv| sv.deref().clone()); @@ -357,15 +357,15 @@ impl CommonItemAttributes { ItemStatus::Change { downgrade_with: change.downgrade_with.as_deref().cloned(), upgrade_with: change.upgrade_with.as_deref().cloned(), - from_ident: from_ident.clone(), - from_type: Box::new(from_ty.clone()), - to_ident: ident, - to_type: Box::new(ty), + previous_ident: previous_ident.clone(), + previous_type: Box::new(previous_type.clone()), + current_ident: ident, + current_type: Box::new(ty), }, ); - ident = from_ident; - ty = from_ty; + ident = previous_ident; + ty = previous_type; } // After the last iteration above (if any) we use the ident for the @@ -389,7 +389,7 @@ impl CommonItemAttributes { let mut actions = BTreeMap::new(); for change in self.changes.iter().rev() { - let from_ident = if let Some(from) = change.from_name.as_deref() { + let previous_ident = if let Some(from) = change.previous_name.as_deref() { format_ident!("{from}").into() } else { ident.clone() @@ -397,8 +397,8 @@ impl CommonItemAttributes { // TODO (@Techassi): This is an awful lot of cloning, can we get // rid of it? - let from_ty = change - .from_type + let previous_type = change + .previous_type .as_ref() .map_or_else(|| ty.clone(), |sv| sv.deref().clone()); @@ -407,15 +407,15 @@ impl CommonItemAttributes { ItemStatus::Change { downgrade_with: change.downgrade_with.as_deref().cloned(), upgrade_with: change.upgrade_with.as_deref().cloned(), - from_ident: from_ident.clone(), - from_type: Box::new(from_ty.clone()), - to_ident: ident, - to_type: Box::new(ty), + previous_ident: previous_ident.clone(), + previous_type: Box::new(previous_type.clone()), + current_ident: ident, + current_type: Box::new(ty), }, ); - ident = from_ident; - ty = from_ty; + ident = previous_ident; + ty = previous_type; } // After the last iteration above (if any) we use the ident for the @@ -477,17 +477,17 @@ fn default_default_fn() -> SpannedValue { /// For the changed() action /// /// Example usage: -/// - `changed(since = "...", from_name = "...")` -/// - `changed(since = "...", from_name = "...", from_type="...")` -/// - `changed(since = "...", from_name = "...", from_type="...", upgrade_with = "...")` -/// - `changed(since = "...", from_name = "...", from_type="...", downgrade_with = "...")` -/// - `changed(since = "...", from_docs = "...")` +/// - `changed(since = "...", previous_name = "...")` +/// - `changed(since = "...", previous_name = "...", previous_type="...")` +/// - `changed(since = "...", previous_name = "...", previous_type="...", upgrade_with = "...")` +/// - `changed(since = "...", previous_name = "...", previous_type="...", downgrade_with = "...")` +/// - `changed(since = "...", previous_docs = "...")` #[derive(Clone, Debug, FromMeta)] pub struct ChangedAttributes { pub since: SpannedValue, - pub from_name: Option>, - pub from_type: Option>, - pub from_docs: Option>, + pub previous_name: Option>, + pub previous_type: Option>, + pub previous_docs: Option>, pub upgrade_with: Option>, pub downgrade_with: Option>, } diff --git a/crates/stackable-versioned-macros/src/attrs/item/variant.rs b/crates/stackable-versioned-macros/src/attrs/item/variant.rs index 06cd4b3ed..4fe85072b 100644 --- a/crates/stackable-versioned-macros/src/attrs/item/variant.rs +++ b/crates/stackable-versioned-macros/src/attrs/item/variant.rs @@ -62,12 +62,12 @@ impl VariantAttributes { // Validate names of renames for change in &self.common.changes { - if let Some(from_name) = &change.from_name - && !is_case(from_name.as_str(), Case::Pascal) + if let Some(previous_name) = &change.previous_name + && !is_case(previous_name.as_str(), Case::Pascal) { errors.push( Error::custom("renamed variant must use PascalCase") - .with_span(&from_name.span()), + .with_span(&previous_name.span()), ); } } diff --git a/crates/stackable-versioned-macros/src/codegen/changes.rs b/crates/stackable-versioned-macros/src/codegen/changes.rs index 38f1112b5..6185b9b99 100644 --- a/crates/stackable-versioned-macros/src/codegen/changes.rs +++ b/crates/stackable-versioned-macros/src/codegen/changes.rs @@ -112,15 +112,15 @@ impl ChangesetExt for BTreeMap { self.insert(version.inner, ItemStatus::NotPresent) } ItemStatus::Change { - from_ident, - from_type, + previous_ident, + previous_type, .. } => self.insert( version.inner, ItemStatus::NoChange { previously_deprecated: false, - ident: from_ident.clone(), - ty: from_type.clone(), + ident: previous_ident.clone(), + ty: previous_type.clone(), }, ), ItemStatus::Deprecation { previous_ident, .. } => self.insert( @@ -149,8 +149,10 @@ impl ChangesetExt for BTreeMap { let (ident, ty, previously_deprecated) = match status { ItemStatus::Addition { ident, ty, .. } => (ident, ty, false), ItemStatus::Change { - to_ident, to_type, .. - } => (to_ident, to_type, false), + current_ident, + current_type, + .. + } => (current_ident, current_type, false), ItemStatus::Deprecation { ident, .. } => { (ident, &Box::new(ty.clone()), true) } @@ -176,8 +178,10 @@ impl ChangesetExt for BTreeMap { let (ident, ty, previously_deprecated) = match status { ItemStatus::Addition { ident, ty, .. } => (ident, ty, false), ItemStatus::Change { - to_ident, to_type, .. - } => (to_ident, to_type, false), + current_ident, + current_type, + .. + } => (current_ident, current_type, false), ItemStatus::NoChange { previously_deprecated, ident, diff --git a/crates/stackable-versioned-macros/src/codegen/item/field.rs b/crates/stackable-versioned-macros/src/codegen/item/field.rs index 78e80cd49..71ae39bd6 100644 --- a/crates/stackable-versioned-macros/src/codegen/item/field.rs +++ b/crates/stackable-versioned-macros/src/codegen/item/field.rs @@ -126,10 +126,12 @@ impl VersionedField { pub #ident: #ty, }), ItemStatus::Change { - to_ident, to_type, .. + current_ident, + current_type, + .. } => Some(quote! { #attributes - pub #to_ident: #to_type, + pub #current_ident: #current_type, }), ItemStatus::Deprecation { ident: field_ident, @@ -239,21 +241,21 @@ impl VersionedField { ItemStatus::Change { downgrade_with, upgrade_with, - from_ident, - to_ident, + previous_ident, + current_ident, .. }, ) => match direction { Direction::Upgrade => Some(self.generate_from_impl_field( - to_ident, + current_ident, from_struct_ident, - from_ident, + previous_ident, upgrade_with.as_ref(), )), Direction::Downgrade => Some(self.generate_from_impl_field( - from_ident, + previous_ident, from_struct_ident, - to_ident, + current_ident, downgrade_with.as_ref(), )), }, diff --git a/crates/stackable-versioned-macros/src/codegen/item/mod.rs b/crates/stackable-versioned-macros/src/codegen/item/mod.rs index 9696b7adb..f2fd6f897 100644 --- a/crates/stackable-versioned-macros/src/codegen/item/mod.rs +++ b/crates/stackable-versioned-macros/src/codegen/item/mod.rs @@ -16,7 +16,7 @@ pub use variant::*; /// Generates the attributes of an item (field or variant) for the provided `version`. /// -/// If the docs of the item are changed in a later version (via `from_docs`), the original doc +/// If the docs of the item are changed in a later version (via `previous_docs`), the original doc /// comments are replaced by the docs which are valid in `version`. pub fn generate_attributes( original_attributes: &[Attribute], @@ -51,10 +51,10 @@ pub enum ItemStatus { Change { downgrade_with: Option, upgrade_with: Option, - from_ident: IdentString, - to_ident: IdentString, - from_type: Box, - to_type: Box, + previous_ident: IdentString, + current_ident: IdentString, + previous_type: Box, + current_type: Box, }, Deprecation { previous_ident: IdentString, @@ -74,7 +74,8 @@ impl ItemStatus { match &self { Self::Addition { ident, .. } | Self::Change { - to_ident: ident, .. + current_ident: ident, + .. } | Self::Deprecation { ident, .. } | Self::NoChange { ident, .. } => ident, diff --git a/crates/stackable-versioned-macros/src/codegen/item/variant.rs b/crates/stackable-versioned-macros/src/codegen/item/variant.rs index 141f90197..22bf43da0 100644 --- a/crates/stackable-versioned-macros/src/codegen/item/variant.rs +++ b/crates/stackable-versioned-macros/src/codegen/item/variant.rs @@ -99,9 +99,9 @@ impl VersionedVariant { #attributes #ident #fields, }), - ItemStatus::Change { to_ident, .. } => Some(quote! { + ItemStatus::Change { current_ident, .. } => Some(quote! { #attributes - #to_ident #fields, + #current_ident #fields, }), ItemStatus::Deprecation { ident, note, .. } => { // FIXME (@Techassi): Emitting the deprecated attribute diff --git a/crates/stackable-versioned-macros/src/lib.rs b/crates/stackable-versioned-macros/src/lib.rs index 5050ae8f1..b99f78c7d 100644 --- a/crates/stackable-versioned-macros/src/lib.rs +++ b/crates/stackable-versioned-macros/src/lib.rs @@ -495,15 +495,15 @@ mod utils; /// or combine multiple changes. Available arguments are: /// /// - `since` to indicate since which version the item is changed. -/// - `from_name` to indicate from which previous name the field is renamed. -/// - `from_type` to indicate from which previous type the field is changed. -/// - `from_docs` to provide the previous doc comments of the item. +/// - `previous_name` to declare the previous name of the field. +/// - `previous_type` to declare the previous type of the field. +/// - `previous_docs` to declare the previous doc comments of the item. /// - `upgrade_with` to provide a custom upgrade function. This argument can -/// only be used in combination with the `from_type` argument. The expected +/// only be used in combination with the `previous_type` argument. The expected /// function signature is: `fn (OLD_TYPE) -> NEW_TYPE`. This function must /// not fail. /// - `downgrade_with` to provide a custom downgrade function. This argument can -/// only be used in combination with the `from_type` argument. The expected +/// only be used in combination with the `previous_type` argument. The expected /// function signature is: `fn (NEW_TYPE) -> OLD_TYPE`. This function must /// not fail. /// ``` @@ -565,10 +565,10 @@ mod utils; /// /// #### Changed Docs /// -/// The doc comments of an item can be changed using the `from_docs` argument. +/// The doc comments of an item can be changed using the `previous_docs` argument. /// The doc comments attached to the item are used after the version of the /// last relevant change. All earlier versions use the doc comments provided via -/// `from_docs` instead. This is especially useful to adjust the description of +/// `previous_docs` instead. This is especially useful to adjust the description of /// a field in the generated CRD schema without changing it for older versions. /// /// ``` @@ -588,7 +588,7 @@ mod utils; /// Expand Generated Code /// /// 1. In version `v1alpha1` the field uses the doc comments provided via -/// `from_docs`. +/// `previous_docs`. /// 2. In the next version, `v1beta1`, the field uses the doc comments attached /// to the field. /// diff --git a/crates/stackable-versioned/README.md b/crates/stackable-versioned/README.md index c59960d00..e3d5c25d9 100644 --- a/crates/stackable-versioned/README.md +++ b/crates/stackable-versioned/README.md @@ -30,7 +30,7 @@ struct Foo { /// My docs #[versioned( added(since = "v1alpha1"), - changed(since = "v1beta1", from_name = "gau"), + changed(since = "v1beta1", previous_name = "gau"), deprecated(since = "v2", note = "not required anymore") )] deprecated_bar: usize, From 6dec7b33abd8de54b5cee6f66d7cfb1e2e577b53 Mon Sep 17 00:00:00 2001 From: Techassi Date: Fri, 23 Oct 2026 09:23:21 +0200 Subject: [PATCH 2/4] chore(operator): Adjust macro arguments for GitSync --- crates/stackable-operator/src/crd/git_sync/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/stackable-operator/src/crd/git_sync/mod.rs b/crates/stackable-operator/src/crd/git_sync/mod.rs index 45b4c8f48..ba3c7d794 100644 --- a/crates/stackable-operator/src/crd/git_sync/mod.rs +++ b/crates/stackable-operator/src/crd/git_sync/mod.rs @@ -69,8 +69,8 @@ pub mod versioned { // See https://github.com/stackabletech/issues/issues/849 for details. #[versioned(changed( since = "v1alpha2", - from_name = "credentials_secret", - from_type = "Option", + previous_name = "credentials_secret", + previous_type = "Option", upgrade_with = credentials_secret_to_basic_auth, downgrade_with = credentials_to_secret ))] From f719ad6478f54944e92b1e33eeafd740f6ab96fc Mon Sep 17 00:00:00 2001 From: Techassi Date: Fri, 23 Oct 2026 09:29:21 +0200 Subject: [PATCH 3/4] test(versioned): Adjust tests to use the renamed arguments --- .../src/codegen/changes.rs | 1 + crates/stackable-versioned-macros/src/lib.rs | 8 ++++---- crates/stackable-versioned-macros/tests/README.md | 4 ++-- .../tests/inputs/fail/changed.rs | 4 ++-- .../tests/inputs/fail/changed.stderr | 14 +++++++------- .../tests/inputs/fail/spec_suffix.rs | 2 +- .../tests/inputs/pass/basic.rs | 2 +- .../tests/inputs/pass/conversion_tracking.rs | 2 +- .../inputs/pass/conversion_tracking_generics.rs | 2 +- .../tests/inputs/pass/crate_overrides.rs | 2 +- .../tests/inputs/pass/crate_overrides_only_kube.rs | 2 +- .../tests/inputs/pass/docs.rs | 14 +++++++------- .../tests/inputs/pass/downgrade_with.rs | 4 ++-- .../tests/inputs/pass/enum_fields.rs | 4 ++-- .../tests/inputs/pass/hint_map.rs | 2 +- .../tests/inputs/pass/renamed_field.rs | 2 +- .../tests/inputs/pass/renamed_kind.rs | 2 +- crates/stackable-versioned/tests/person.rs | 2 +- 18 files changed, 37 insertions(+), 36 deletions(-) diff --git a/crates/stackable-versioned-macros/src/codegen/changes.rs b/crates/stackable-versioned-macros/src/codegen/changes.rs index 6185b9b99..3e1355a4f 100644 --- a/crates/stackable-versioned-macros/src/codegen/changes.rs +++ b/crates/stackable-versioned-macros/src/codegen/changes.rs @@ -100,6 +100,7 @@ pub trait ChangesetExt { } impl ChangesetExt for BTreeMap { + #[allow(clippy::too_many_lines)] fn insert_container_versions(&mut self, versions: &[VersionDefinition], ty: &Type) { for version in versions { if self.contains_key(&version.inner) { diff --git a/crates/stackable-versioned-macros/src/lib.rs b/crates/stackable-versioned-macros/src/lib.rs index b99f78c7d..ba6325522 100644 --- a/crates/stackable-versioned-macros/src/lib.rs +++ b/crates/stackable-versioned-macros/src/lib.rs @@ -513,8 +513,8 @@ mod utils; /// pub struct Foo { /// #[versioned(changed( /// since = "v1beta1", -/// from_name = "prev_bar", -/// from_type = "u16", +/// previous_name = "prev_bar", +/// previous_type = "u16", /// downgrade_with = usize_to_u16 /// ))] /// bar: usize, @@ -577,7 +577,7 @@ mod utils; /// mod versioned { /// pub struct Foo { /// /// The number of bars. -/// #[versioned(changed(since = "v1beta1", from_docs = "The bar."))] +/// #[versioned(changed(since = "v1beta1", previous_docs = "The bar."))] /// bar: usize, /// baz: bool, /// } @@ -701,7 +701,7 @@ mod utils; /// #[versioned(version(name = "v1alpha1"), version(name = "v1beta1"))] /// mod versioned { /// pub struct Foo { -/// #[versioned(changed(since = "v1beta1", from_type = "Vec"), hint(vec))] +/// #[versioned(changed(since = "v1beta1", previous_type = "Vec"), hint(vec))] /// bar: Vec, /// baz: bool, /// } diff --git a/crates/stackable-versioned-macros/tests/README.md b/crates/stackable-versioned-macros/tests/README.md index c90d6c4f6..ca2daa372 100644 --- a/crates/stackable-versioned-macros/tests/README.md +++ b/crates/stackable-versioned-macros/tests/README.md @@ -43,8 +43,8 @@ use stackable_versioned::versioned; // --- <- See here! pub(crate) struct Foo { #[versioned( - changed(since = "v1beta1", from_name = "jjj", from_type = "u8"), - changed(since = "v1", from_type = "u16"), + changed(since = "v1beta1", previous_name = "jjj", previous_type = "u8"), + changed(since = "v1", previous_type = "u16"), )] bar: usize, baz: bool, diff --git a/crates/stackable-versioned-macros/tests/inputs/fail/changed.rs b/crates/stackable-versioned-macros/tests/inputs/fail/changed.rs index dbcaefc96..df9527537 100644 --- a/crates/stackable-versioned-macros/tests/inputs/fail/changed.rs +++ b/crates/stackable-versioned-macros/tests/inputs/fail/changed.rs @@ -9,8 +9,8 @@ use stackable_versioned_macros::versioned; mod versioned { struct Foo { #[versioned( - changed(since = "v1beta1", from_name = "deprecated_bar"), - changed(since = "v1", from_name = "deprecated_baz"), + changed(since = "v1beta1", previous_name = "deprecated_bar"), + changed(since = "v1", previous_name = "deprecated_baz"), changed(since = "v2") )] bar: usize, diff --git a/crates/stackable-versioned-macros/tests/inputs/fail/changed.stderr b/crates/stackable-versioned-macros/tests/inputs/fail/changed.stderr index 417ca1250..a766cb4f2 100644 --- a/crates/stackable-versioned-macros/tests/inputs/fail/changed.stderr +++ b/crates/stackable-versioned-macros/tests/inputs/fail/changed.stderr @@ -1,16 +1,16 @@ error: the previous name must not start with the deprecation prefix - --> tests/inputs/fail/changed.rs:12:52 + --> tests/inputs/fail/changed.rs:12:56 | -12 | changed(since = "v1beta1", from_name = "deprecated_bar"), - | ^^^^^^^^^^^^^^^^ +12 | changed(since = "v1beta1", previous_name = "deprecated_bar"), + | ^^^^^^^^^^^^^^^^ error: the previous name must not start with the deprecation prefix - --> tests/inputs/fail/changed.rs:13:47 + --> tests/inputs/fail/changed.rs:13:51 | -13 | changed(since = "v1", from_name = "deprecated_baz"), - | ^^^^^^^^^^^^^^^^ +13 | changed(since = "v1", previous_name = "deprecated_baz"), + | ^^^^^^^^^^^^^^^^ -error: `from_name`, `from_type` and `from_docs` are unset. Is this `changed()` action needed? +error: `previous_name`, `previous_type` and `previous_docs` are unset. Is this `changed()` action needed? --> tests/inputs/fail/changed.rs:14:29 | 14 | changed(since = "v2") diff --git a/crates/stackable-versioned-macros/tests/inputs/fail/spec_suffix.rs b/crates/stackable-versioned-macros/tests/inputs/fail/spec_suffix.rs index cd5338233..33cfaf4ea 100644 --- a/crates/stackable-versioned-macros/tests/inputs/fail/spec_suffix.rs +++ b/crates/stackable-versioned-macros/tests/inputs/fail/spec_suffix.rs @@ -13,7 +13,7 @@ mod versioned { pub struct Foo { #[versioned( added(since = "v1beta1"), - changed(since = "v1", from_name = "bah", from_type = "u16") + changed(since = "v1", previous_name = "bah", previous_type = "u16") )] bar: usize, baz: bool, diff --git a/crates/stackable-versioned-macros/tests/inputs/pass/basic.rs b/crates/stackable-versioned-macros/tests/inputs/pass/basic.rs index 69558b47e..5a6f0f1d0 100644 --- a/crates/stackable-versioned-macros/tests/inputs/pass/basic.rs +++ b/crates/stackable-versioned-macros/tests/inputs/pass/basic.rs @@ -26,7 +26,7 @@ pub(crate) mod versioned { struct FooSpec { #[versioned( added(since = "v1beta1"), - changed(since = "v1", from_name = "bah", from_type = "u16", downgrade_with = usize_to_u16) + changed(since = "v1", previous_name = "bah", previous_type = "u16", downgrade_with = usize_to_u16) )] bar: usize, baz: bool, diff --git a/crates/stackable-versioned-macros/tests/inputs/pass/conversion_tracking.rs b/crates/stackable-versioned-macros/tests/inputs/pass/conversion_tracking.rs index dd3ecd729..f7cc4004e 100644 --- a/crates/stackable-versioned-macros/tests/inputs/pass/conversion_tracking.rs +++ b/crates/stackable-versioned-macros/tests/inputs/pass/conversion_tracking.rs @@ -18,7 +18,7 @@ pub(crate) mod versioned { ))] #[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, CustomResource)] pub(crate) struct FooSpec { - #[versioned(added(since = "v1beta1"), changed(since = "v1", from_name = "bah"))] + #[versioned(added(since = "v1beta1"), changed(since = "v1", previous_name = "bah"))] bar: usize, baz: bool, } diff --git a/crates/stackable-versioned-macros/tests/inputs/pass/conversion_tracking_generics.rs b/crates/stackable-versioned-macros/tests/inputs/pass/conversion_tracking_generics.rs index 33bd3091e..2e474e978 100644 --- a/crates/stackable-versioned-macros/tests/inputs/pass/conversion_tracking_generics.rs +++ b/crates/stackable-versioned-macros/tests/inputs/pass/conversion_tracking_generics.rs @@ -18,7 +18,7 @@ pub(crate) mod versioned { ))] #[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, CustomResource)] pub(crate) struct FooSpec { - #[versioned(added(since = "v1beta1"), changed(since = "v1", from_name = "bah"))] + #[versioned(added(since = "v1beta1"), changed(since = "v1", previous_name = "bah"))] bar: usize, #[versioned(nested)] diff --git a/crates/stackable-versioned-macros/tests/inputs/pass/crate_overrides.rs b/crates/stackable-versioned-macros/tests/inputs/pass/crate_overrides.rs index 5551ef168..2c57fa7de 100644 --- a/crates/stackable-versioned-macros/tests/inputs/pass/crate_overrides.rs +++ b/crates/stackable-versioned-macros/tests/inputs/pass/crate_overrides.rs @@ -21,7 +21,7 @@ pub mod versioned { kube::CustomResource, )] pub struct FooSpec { - #[versioned(added(since = "v1beta1"), changed(since = "v1", from_name = "bah"))] + #[versioned(added(since = "v1beta1"), changed(since = "v1", previous_name = "bah"))] bar: usize, baz: bool, } diff --git a/crates/stackable-versioned-macros/tests/inputs/pass/crate_overrides_only_kube.rs b/crates/stackable-versioned-macros/tests/inputs/pass/crate_overrides_only_kube.rs index 996ab8564..f2c65607a 100644 --- a/crates/stackable-versioned-macros/tests/inputs/pass/crate_overrides_only_kube.rs +++ b/crates/stackable-versioned-macros/tests/inputs/pass/crate_overrides_only_kube.rs @@ -21,7 +21,7 @@ pub mod versioned { kube::CustomResource, )] pub struct FooSpec { - #[versioned(added(since = "v1beta1"), changed(since = "v1", from_name = "bah"))] + #[versioned(added(since = "v1beta1"), changed(since = "v1", previous_name = "bah"))] bar: usize, baz: bool, } diff --git a/crates/stackable-versioned-macros/tests/inputs/pass/docs.rs b/crates/stackable-versioned-macros/tests/inputs/pass/docs.rs index 13f7c8d11..2a02bc331 100644 --- a/crates/stackable-versioned-macros/tests/inputs/pass/docs.rs +++ b/crates/stackable-versioned-macros/tests/inputs/pass/docs.rs @@ -32,16 +32,16 @@ mod versioned { baz: String, /// This is will keep changing over time. - #[versioned(changed(since = "v1beta1", from_name = "qoox"))] - #[versioned(changed(since = "v1", from_name = "qaax"))] + #[versioned(changed(since = "v1beta1", previous_name = "qoox"))] + #[versioned(changed(since = "v1", previous_name = "qaax"))] quux: String, /// The docs of this field changed in v1beta1 and v2. #[versioned( - changed(since = "v1beta1", from_docs = "These are the docs in v1alpha1."), + changed(since = "v1beta1", previous_docs = "These are the docs in v1alpha1."), changed( since = "v2", - from_docs = r#" + previous_docs = r#" These are the docs from v1beta1 until v1. Multi-line docs are also supported. @@ -55,8 +55,8 @@ mod versioned { /// The docs of this field changed in v1, while it was renamed in v1beta1. #[versioned( - changed(since = "v1beta1", from_name = "waldo"), - changed(since = "v1", from_docs = "These are the docs before v1.") + changed(since = "v1beta1", previous_name = "waldo"), + changed(since = "v1", previous_docs = "These are the docs before v1.") )] fred: String, } @@ -65,7 +65,7 @@ mod versioned { #[derive(Default)] enum Bar { /// The docs of this variant changed in v1. - #[versioned(changed(since = "v1", from_docs = "These are the docs before v1."))] + #[versioned(changed(since = "v1", previous_docs = "These are the docs before v1."))] #[default] Baz, } diff --git a/crates/stackable-versioned-macros/tests/inputs/pass/downgrade_with.rs b/crates/stackable-versioned-macros/tests/inputs/pass/downgrade_with.rs index eddb3a609..68e91cf83 100644 --- a/crates/stackable-versioned-macros/tests/inputs/pass/downgrade_with.rs +++ b/crates/stackable-versioned-macros/tests/inputs/pass/downgrade_with.rs @@ -8,8 +8,8 @@ mod versioned { // This tests two additional things: // - that both unquoted and quoted usage works // - that the renamed name does get picked up correctly by the conversion function - changed(since = "v1", from_type = "u16", from_name = "bar", downgrade_with = u32_to_u16), - changed(since = "v2", from_type = "u32", downgrade_with = "u64_to_u32") + changed(since = "v1", previous_type = "u16", previous_name = "bar", downgrade_with = u32_to_u16), + changed(since = "v2", previous_type = "u32", downgrade_with = "u64_to_u32") )] baz: u64, } diff --git a/crates/stackable-versioned-macros/tests/inputs/pass/enum_fields.rs b/crates/stackable-versioned-macros/tests/inputs/pass/enum_fields.rs index 9b29501a1..87746533d 100644 --- a/crates/stackable-versioned-macros/tests/inputs/pass/enum_fields.rs +++ b/crates/stackable-versioned-macros/tests/inputs/pass/enum_fields.rs @@ -4,7 +4,7 @@ use stackable_versioned::versioned; // --- pub mod versioned { enum Foo { - #[versioned(changed(since = "v1alpha2", from_name = "PrevA"))] + #[versioned(changed(since = "v1alpha2", previous_name = "PrevA"))] A { aa: usize, aaa: u64, @@ -15,7 +15,7 @@ pub mod versioned { } enum Bar { - #[versioned(changed(since = "v1alpha2", from_name = "PrevA"))] + #[versioned(changed(since = "v1alpha2", previous_name = "PrevA"))] A(A), B {}, } diff --git a/crates/stackable-versioned-macros/tests/inputs/pass/hint_map.rs b/crates/stackable-versioned-macros/tests/inputs/pass/hint_map.rs index 9e9784615..054abb029 100644 --- a/crates/stackable-versioned-macros/tests/inputs/pass/hint_map.rs +++ b/crates/stackable-versioned-macros/tests/inputs/pass/hint_map.rs @@ -7,7 +7,7 @@ use stackable_versioned::versioned; pub(crate) mod versioned { pub(crate) struct Foo { #[versioned( - changed(since = "v1alpha2", from_type = "HashMap"), + changed(since = "v1alpha2", previous_type = "HashMap"), hint(map) )] bar: HashMap, diff --git a/crates/stackable-versioned-macros/tests/inputs/pass/renamed_field.rs b/crates/stackable-versioned-macros/tests/inputs/pass/renamed_field.rs index f8c78e479..8ad49c053 100644 --- a/crates/stackable-versioned-macros/tests/inputs/pass/renamed_field.rs +++ b/crates/stackable-versioned-macros/tests/inputs/pass/renamed_field.rs @@ -8,7 +8,7 @@ use stackable_versioned::versioned; // --- mod versioned { struct Foo { - #[versioned(changed(since = "v1beta1", from_name = "bat"))] + #[versioned(changed(since = "v1beta1", previous_name = "bat"))] bar: usize, baz: bool, } diff --git a/crates/stackable-versioned-macros/tests/inputs/pass/renamed_kind.rs b/crates/stackable-versioned-macros/tests/inputs/pass/renamed_kind.rs index f00d811c7..d63bbdabe 100644 --- a/crates/stackable-versioned-macros/tests/inputs/pass/renamed_kind.rs +++ b/crates/stackable-versioned-macros/tests/inputs/pass/renamed_kind.rs @@ -17,7 +17,7 @@ pub mod versioned { kube::CustomResource, )] pub struct FooSpec { - #[versioned(added(since = "v1beta1"), changed(since = "v1", from_name = "bah"))] + #[versioned(added(since = "v1beta1"), changed(since = "v1", previous_name = "bah"))] bar: usize, baz: bool, } diff --git a/crates/stackable-versioned/tests/person.rs b/crates/stackable-versioned/tests/person.rs index 7f3bf16a5..949a5e05c 100644 --- a/crates/stackable-versioned/tests/person.rs +++ b/crates/stackable-versioned/tests/person.rs @@ -72,7 +72,7 @@ pub mod versioned { // Afterwards we figured let's be more flexible and accept any arbitrary String. // FIXME: The roundtrips are currently broken, see the `roundtrip_test_data` below. - #[versioned(added(since = "v2"), changed(since = "v3", from_type = "Gender"))] + #[versioned(added(since = "v2"), changed(since = "v3", previous_type = "Gender"))] gender: String, // TODO (@Techassi): Dealing with Default here is kinda meh UX wise. What would really help From 326ce720247d09a10066117aeba676bb1b9e1317 Mon Sep 17 00:00:00 2001 From: Techassi Date: Fri, 23 Oct 2026 11:45:28 +0200 Subject: [PATCH 4/4] chore(versioned): Add changelog entry --- crates/stackable-versioned/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/stackable-versioned/CHANGELOG.md b/crates/stackable-versioned/CHANGELOG.md index e1e03fea9..243db790a 100644 --- a/crates/stackable-versioned/CHANGELOG.md +++ b/crates/stackable-versioned/CHANGELOG.md @@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file. ### Changed +- BREAKING: Rename all `from_` arguments to `previous_` ([#1313]). - BREAKING: `stackable_versioned::ChangedValue`'s `value` field type is now `serde_json::Value` instead of `yaml_serde::Value` ([#1307]). @@ -29,6 +30,7 @@ All notable changes to this project will be documented in this file. [#1307]: https://github.com/stackabletech/operator-rs/pull/1307 [#1309]: https://github.com/stackabletech/operator-rs/pull/1309 [#1312]: https://github.com/stackabletech/operator-rs/pull/1312 +[#1313]: https://github.com/stackabletech/operator-rs/pull/1313 ## [0.13.0] - 2026-10-14