Skip to content

Commit db85e29

Browse files
committed
chore(stackable-versioned): Use jsonPath instead of fieldName as field name
1 parent 790bfb5 commit db85e29

File tree

6 files changed

+26
-26
lines changed

6 files changed

+26
-26
lines changed

crates/stackable-versioned-macros/src/codegen/container/struct/conversion.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ impl Struct {
280280
Some(quote! {
281281
// NOTE (@Techassi): This is an awkward thing to do. Can we possibly use &str for the keys here?
282282
if let Some(upgrades) = status.changes().upgrades.remove(&#next_version_string.to_owned()) {
283-
for #versioned_path::ChangedValue { field_name, value } in upgrades {
284-
match field_name {
283+
for #versioned_path::ChangedValue { json_path, value } in upgrades {
284+
match json_path {
285285
#match_arms
286286
_ => unreachable!(),
287287
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ impl VersionedField {
316316

317317
Some(quote! {
318318
upgrades.push(#versioned_path::ChangedValue {
319-
field_name: #json_path_ident,
319+
json_path: #json_path_ident,
320320
value: #serde_yaml_path::to_value(&#from_struct_ident.#ident).unwrap(),
321321
});
322322
})
@@ -347,7 +347,7 @@ impl VersionedField {
347347
let json_path_ident = format_ident!("__sv_{}_path", ident.as_ident());
348348

349349
Some(quote! {
350-
field_name if field_name == #json_path_ident => {
350+
json_path if json_path == #json_path_ident => {
351351
spec.#ident = serde_yaml::from_value(value).unwrap();
352352
},
353353
})

crates/stackable-versioned-macros/tests/snapshots/stackable_versioned_macros__snapshots__pass@conversion_tracking.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/[email protected]

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/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub struct ChangedValues {
8080
#[serde(rename_all = "camelCase")]
8181
pub struct ChangedValue {
8282
/// The name of the field of the custom resource this value is for.
83-
pub field_name: String,
83+
pub json_path: String,
8484

8585
/// The value to be used when upgrading or downgrading the custom resource.
8686
#[schemars(schema_with = "raw_object_schema")]

crates/stackable-versioned/tests/snapshots/conversions__pass@persons_to_v1alpha1.json.snap

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

0 commit comments

Comments
 (0)