Skip to content

Commit 7b39422

Browse files
authored
fix(stackable-versioned): Emit correct match arms for version enum (#1065)
* fix(stackable-versioned): Generate correct match arms for as_str function * fix(stackable-versioned): Fully qualify variants in other match arms * test(stackable-versioned): Add integration test for merged_crd * chore(stackable-versioned): Add changelog entry * test(stackable-versioned): Improve merged_crd integration test * test(stackable-versioned): Simplify merged_crd test
1 parent 7d83ffe commit 7b39422

12 files changed

+183
-157
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,19 +280,19 @@ impl Struct {
280280
impl #enum_ident {
281281
pub fn as_version_str(&self) -> &str {
282282
match self {
283-
#(#variant_idents => #variant_strings),*
283+
#(#enum_ident::#variant_idents => #variant_strings),*
284284
}
285285
}
286286

287287
pub fn as_api_version_str(&self) -> &str {
288288
match self {
289-
#(#variant_idents => #api_versions),*
289+
#(#enum_ident::#variant_idents => #api_versions),*
290290
}
291291
}
292292

293293
pub fn from_api_version(api_version: &str) -> Result<Self, #unknown_desired_api_version_error> {
294294
match api_version {
295-
#(#api_versions => Ok(Self::#variant_idents)),*,
295+
#(#api_versions => Ok(#enum_ident::#variant_idents)),*,
296296
_ => Err(#unknown_desired_api_version_error {
297297
api_version: api_version.to_owned(),
298298
}),

crates/stackable-versioned-macros/tests/snapshots/stackable_versioned_macros__snapshot_tests__k8s@basic.rs.snap

Lines changed: 9 additions & 9 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__snapshot_tests__k8s@conversion_tracking.rs.snap

Lines changed: 9 additions & 9 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__snapshot_tests__k8s@crate_overrides.rs.snap

Lines changed: 9 additions & 9 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__snapshot_tests__k8s@module.rs.snap

Lines changed: 18 additions & 18 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__snapshot_tests__k8s@module_preserve.rs.snap

Lines changed: 18 additions & 18 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__snapshot_tests__k8s@renamed_kind.rs.snap

Lines changed: 9 additions & 9 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__snapshot_tests__k8s@shortnames.rs.snap

Lines changed: 3 additions & 3 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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ All notable changes to this project will be documented in this file.
3232

3333
### Fixed
3434

35+
- Fix incorrectly generated match arms for the version enum ([#1065]).
3536
- Fix regression introduced in [#1033]. The `#[kube(status = ...)]` attribute is generated correctly
3637
again ([#1046]).
3738
- Correctly handle fields added in later versions ([#1031]).
@@ -55,6 +56,7 @@ All notable changes to this project will be documented in this file.
5556
[#1050]: https://github.com/stackabletech/operator-rs/pull/1050
5657
[#1059]: https://github.com/stackabletech/operator-rs/pull/1059
5758
[#1061]: https://github.com/stackabletech/operator-rs/pull/1061
59+
[#1065]: https://github.com/stackabletech/operator-rs/pull/1065
5860

5961
## [0.7.1] - 2025-04-02
6062

0 commit comments

Comments
 (0)