[v11.0.x] Annotations: Fix composite store read (#94180)

* Annotations: Fix composite store read (#94158)

* Annotations: Fix composite store read

* Add test

* check error

(cherry picked from commit bd1741653d)

* remove unused file

* re-format
This commit is contained in:
Alexander Zobnin
2024-10-03 17:33:13 +02:00
committed by GitHub
parent 8801d0a781
commit 84f806b573
10 changed files with 91 additions and 68 deletions
@@ -75,7 +75,7 @@ func (r *RepositoryImpl) Find(ctx context.Context, query *annotations.ItemQuery)
// Search without dashboard UID filter is expensive, so check without access control first
if query.DashboardID == 0 && query.DashboardUID == "" {
// Return early if no annotations found, it's not necessary to perform expensive access control filtering
res, err := r.reader.Get(ctx, query, &accesscontrol.AccessResources{
res, err := r.reader.Get(ctx, *query, &accesscontrol.AccessResources{
SkipAccessControlFilter: true,
})
if err != nil || len(res) == 0 {
@@ -93,12 +93,12 @@ func (r *RepositoryImpl) Find(ctx context.Context, query *annotations.ItemQuery)
// Iterate over available annotations until query limit is reached
// or all available dashboards are checked
for len(results) < int(query.Limit) {
resources, err := r.authZ.Authorize(ctx, query)
resources, err := r.authZ.Authorize(ctx, *query)
if err != nil {
return nil, err
}
res, err := r.reader.Get(ctx, query, resources)
res, err := r.reader.Get(ctx, *query, resources)
if err != nil {
return nil, err
}
@@ -119,5 +119,5 @@ func (r *RepositoryImpl) Delete(ctx context.Context, params *annotations.DeleteP
}
func (r *RepositoryImpl) FindTags(ctx context.Context, query *annotations.TagsQuery) (annotations.FindTagsResult, error) {
return r.reader.GetTags(ctx, query)
return r.reader.GetTags(ctx, *query)
}