refactor(sidekick/rust): unify resource name template generation#4538
refactor(sidekick/rust): unify resource name template generation#4538haphungw wants to merge 3 commits intogoogleapis:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors resource identification logic, primarily by inverting the priority of heuristic over explicit identification in resource_identification.go. A significant change in internal/sidekick/rust/annotate.go involves the complete removal of the resourceNameCandidateField struct and related functions for identifying and annotating resource name fields within methodAnnotation, along with the ResourceNameFields and HasResourceNameFields fields themselves. While a new HasResourceNameArgs field was added to pathBindingAnnotation for template simplification, a critical issue was introduced: the grpc-client/transport.rs.mustache template now attempts to use the removed Codec.HasResourceNameFields and Codec.ResourceNameFields for detailed tracing attributes, which will lead to code generation failures or incorrect output due to missing data.
internal/sidekick/rust/templates/grpc-client/transport.rs.mustache
Outdated
Show resolved
Hide resolved
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4538 +/- ##
=======================================
Coverage 79.74% 79.74%
=======================================
Files 109 109
Lines 9118 9118
=======================================
Hits 7271 7271
Misses 1339 1339
Partials 508 508 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
internal/sidekick/rust/templates/crate/src/transport.rs.mustache
Outdated
Show resolved
Hide resolved
fdf4839 to
cb3f783
Compare
5588c42 to
5a6be0e
Compare
|
already included in #4560 |
The Rust generator previously handled explicit fields with
ResourceNameFieldsand heuristic templates withResourceNameTemplatedifferently, creating overly complex branch logic. Both explicit resource reference annotations and path-based heuristics are now unified into a single generation source withTargetResource.This eliminates redundant structs and logic for the codebase, while ensuring that resource names are consistently routed for both heuristic and explicit logic when detailed tracing attributes are enabled.
Fixes #4537