ROX-28697: use Walk instead of GetAll in policy#14747
Conversation
|
Images are ready for the commit at 652f9b4. To use with deploy scripts, first |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #14747 +/- ##
=======================================
Coverage 48.96% 48.96%
=======================================
Files 2550 2550
Lines 187222 187225 +3
=======================================
+ Hits 91665 91667 +2
- Misses 88304 88305 +1
Partials 7253 7253
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a55bdac to
57b0887
Compare
|
It's draft as it's waiting for: |
Signed-off-by: Tomasz Janiszewski <tomek@redhat.com> # Conflicts: # central/policy/datastore/datastore_impl_test.go # central/policy/datastore/singleton.go # central/policy/store/store.go
|
Since #14749 (review) is still in review I decided to fix tests here too but not unskip them as they will be unskipped in the other PR with fix over error string that contains id instead of name |
Reviewer's Guide by SourceryThis pull request replaces the Sequence diagram for fetching all policies using WalksequenceDiagram
participant DS as DataStore
participant S as Store
DS->>S: Walk(ctx, fn)
activate S
loop For each policy in the database
S->>S: fn(policy)
activate S
S-->>DS: error (if any)
deactivate S
end
S-->>DS: error (if any)
deactivate S
Updated class diagram for the Policy StoreclassDiagram
class Store {
<<interface>>
+Search(ctx context.Context, q *v1.Query) ([]search.Result, error)
+Get(ctx context.Context, id string) (*storage.Policy, bool, error)
+GetMany(ctx context.Context, ids []string) ([]*storage.Policy, []int, error)
+Walk(ctx context.Context, fn func(obj *storage.Policy) error) error
+GetIDs(ctx context.Context) ([]string, error)
+Upsert(ctx context.Context, obj *storage.Policy) error
+UpsertMany(ctx context.Context, objs []*storage.Policy) error
+Delete(ctx context.Context, id string) error
}
note for Store "GetAll has been removed and Walk has been added"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @janisz - I've reviewed your changes - here's some feedback:
Overall Comments:
- It looks like you've removed the
GetAllmethod from theStoreinterface, but the mock still has it. - The
eqmatcher in the tests could be improved by usingproto.Equalfor a more robust comparison.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Description
Use Walk instead of GetAll in policies
Testing
Automated testing
How I validated my change
CI
Summary by Sourcery
Replace GetAll method with Walk method in policy-related code to improve iteration and memory efficiency
Enhancements:
Tests:
Chores: