Skip to content

Commit e723c30

Browse files
authored
fix(stackable-versioned): Use crate override in generated code (#1079)
* fix: Use configurable versioned crate instead of hardcoding it * changelog * Put changelog entry in correct file
1 parent 113c4ee commit e723c30

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl Struct {
171171
// names.
172172
let inserts = self.generate_tracking_inserts(direction, next_version, mod_gen_ctx);
173173
let removals = self.generate_tracking_removals(direction, next_version, mod_gen_ctx);
174-
let json_paths = self.generate_json_paths(next_version);
174+
let json_paths = self.generate_json_paths(next_version, mod_gen_ctx);
175175

176176
// TODO (@Techassi): Re-add support for generics
177177
// TODO (@Techassi): We know the status, so we can hard-code it, but hard to track across structs
@@ -288,11 +288,15 @@ impl Struct {
288288
}
289289
}
290290

291-
fn generate_json_paths(&self, next_version: &VersionDefinition) -> Option<TokenStream> {
291+
fn generate_json_paths(
292+
&self,
293+
next_version: &VersionDefinition,
294+
mod_gen_ctx: ModuleGenerationContext<'_>,
295+
) -> Option<TokenStream> {
292296
let json_paths = self
293297
.fields
294298
.iter()
295-
.filter_map(|f| f.generate_for_json_path(next_version))
299+
.filter_map(|f| f.generate_for_json_path(next_version, mod_gen_ctx))
296300
.collect();
297301

298302
Some(json_paths)

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,13 @@ impl VersionedField {
358358
}
359359
}
360360

361-
pub fn generate_for_json_path(&self, next_version: &VersionDefinition) -> Option<TokenStream> {
361+
pub fn generate_for_json_path(
362+
&self,
363+
next_version: &VersionDefinition,
364+
mod_gen_ctx: ModuleGenerationContext<'_>,
365+
) -> Option<TokenStream> {
366+
let versioned_path = &*mod_gen_ctx.crates.versioned;
367+
362368
match (&self.changes, self.nested) {
363369
// If there are no changes and the field also not marked as nested, there is no need to
364370
// generate a path variable for that field as no tracked values need to be applied/inserted
@@ -373,7 +379,7 @@ impl VersionedField {
373379
let field_ident = format_ident!("__sv_{}_path", &self.ident.as_ident());
374380
let child_string = &self.ident.to_string();
375381
Some(quote! {
376-
let #field_ident = ::stackable_versioned::jthong_path(parent, #child_string);
382+
let #field_ident = #versioned_path::jthong_path(parent, #child_string);
377383
})
378384
}
379385
(Some(changes), _) => {
@@ -385,7 +391,7 @@ impl VersionedField {
385391
let child_string = ident.to_string();
386392

387393
Some(quote! {
388-
let #field_ident = ::stackable_versioned::jthong_path(parent, #child_string);
394+
let #field_ident = #versioned_path::jthong_path(parent, #child_string);
389395
})
390396
}
391397
_ => None,

crates/stackable-versioned/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Fixed
8+
9+
- Replace the hardcoded `::stackable_versioned` path in the `tracking_from` function with the configurable crate override ([#1079]).
10+
11+
[#1079]: https://github.com/stackabletech/operator-rs/pull/1079
12+
713
## [0.8.0] - 2025-07-10
814

915
### Added

0 commit comments

Comments
 (0)