fix(gengapic): use recursive resource name heuristic#1698
Closed
quartzmo wants to merge 1 commit intogoogleapis:mainfrom
Closed
fix(gengapic): use recursive resource name heuristic#1698quartzmo wants to merge 1 commit intogoogleapis:mainfrom
quartzmo wants to merge 1 commit intogoogleapis:mainfrom
Conversation
5f86b92 to
68ced14
Compare
Update the resource identifying field heuristic to be recursive.
Satisfies Requirements:
1. **Nested Field Support:** Recursively searches for fields annotated
with `google.api.resource_reference` up to 2 levels deep. This
directly addresses AIP-134 (Update) scenarios where the resource is
often nested (e.g., `req.Secret.Name`).
2. **Tie-breaking:** Prioritizes annotated fields that also appear in
the method's `google.api.http` path template, ensuring the correct
"primary" resource is selected when multiple references exist.
3. **Code Generation:** Returns the full field path (e.g., `secret.name`)
and uses a `fieldGetter` helper to generate idiomatic Go accessors
(e.g., `req.GetSecret().GetName()`), fixing a previous omission where
nested fields could not be accessed.
68ced14 to
b934f91
Compare
Member
Author
|
Replaced by #1722 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor the resource identifying field heuristic to be recursive and address specific gaps in the current implementation.
Satisfies Requirements:
google.api.resource_referenceup to 2 levels deep. This directly addresses AIP-134 (Update) scenarios where the resource is often nested (e.g.,req.Secret.Name).google.api.httppath template, ensuring the correct "primary" resource is selected when multiple references exist.secret.name) to generate idiomatic Go accessors for nested fields (e.g.,req.GetSecret().GetName()), addressing AIP-134 scenarios.TODO (Remaining Requirements from Design):
vocabulary of valid resource types from HTTP path literals. This is
required for legacy services (Compute, SQL, BigQuery) that lack
annotations.
paths and generate code to reassemble multiple request fields into a
single canonical resource name.
(custom verbs) from reconstructed paths.
advanced heuristics to the specific legacy services identified in the
design.
Tests added in
internal/gengapic/resource_name_test.goverify the recursive search and tie-breaking logic.