fix(graph): refactor query method to accept subscriptions directly and add QueryOptions for management group scope#883
Merged
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #883 +/- ##
==========================================
+ Coverage 22.96% 23.13% +0.16%
==========================================
Files 95 95
Lines 5860 5818 -42
==========================================
Hits 1346 1346
+ Misses 4406 4364 -42
Partials 108 108
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…d add QueryOptions for management group scope #882
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.
Description
This pull request refactors how subscription data is passed to Resource Graph queries across the codebase, improving type safety and simplifying the API. It introduces a new
QueryOptionsstruct for optional query features, updates all scanner modules to use amap[string]stringfor subscriptions instead of slices of pointers, and removes redundant code for preparing subscription lists. Additionally, it enables management group scope for policy queries via the new options struct.API and Query Handling Improvements:
GraphQueryClient.Queryto acceptsubscriptionsas amap[string]string(from[]*string), improving clarity and type safety. All call sites in scanner modules are updated accordingly. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]QueryOptionsstruct to control optional query features (e.g.,ManagementGroupScope), and refactored query batching and pagination logic for clarity and maintainability. [1] [2]QueryOptions{ManagementGroupScope: true}where needed.Code Simplification and Cleanup:
Scanner Module Adjustments:
These changes collectively streamline Resource Graph querying, reduce duplicated code, and provide a more flexible and robust interface for future enhancements.
Issue reference
We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.
Please reference the issue this PR will close: #882
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: