Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rules): fix HasParent check and utilify it #1468

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

noahdietz
Copy link
Collaborator

#906 should've been closed by previous PRs, but a user recently reported some issues with it not being completely fixed.

I think they bumped into an edge case where if the resource type wasn't annotated with google.api.resource, the logic that checked if the resource was a child resource by looking for exactly one resource ID segment produced a false positive. It should've been checking for > 1 and accounting for the fact that if there are no patterns (or if it is unannotated), it is also not a child resource/has no parent.

I've centralized an updated implementation in rules/internal/utils and inverted the logic as per the naming hasNoParent -> HasParent.

Also cleans up some variable names/comments in copy-pasted code.

Updates #906

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant