From e582a1c1e17ed64ce073676b678b32c591ca5c38 Mon Sep 17 00:00:00 2001 From: Jacek Wysocki Date: Fri, 9 Aug 2024 09:34:54 +0200 Subject: [PATCH] chore: rename tags in filter --- pkg/repository/testworkflow/filter.go | 14 ++++++++------ pkg/repository/testworkflow/interface.go | 2 +- pkg/repository/testworkflow/mongo.go | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/pkg/repository/testworkflow/filter.go b/pkg/repository/testworkflow/filter.go index 65e777637ca..8e82e686473 100644 --- a/pkg/repository/testworkflow/filter.go +++ b/pkg/repository/testworkflow/filter.go @@ -6,6 +6,8 @@ import ( "github.com/kubeshop/testkube/pkg/api/v1/testkube" ) +var _ Filter = &FilterImpl{} + type FilterImpl struct { FName string FLastNDays int @@ -17,11 +19,11 @@ type FilterImpl struct { FTextSearch string FSelector string FRunnerIds []string - FTags map[string]string + FRunnerTags map[string]string } func NewExecutionsFilter() *FilterImpl { - result := FilterImpl{FPage: 0, FPageSize: PageDefaultLimit, FTags: make(map[string]string)} + result := FilterImpl{FPage: 0, FPageSize: PageDefaultLimit, FRunnerTags: make(map[string]string)} return &result } @@ -73,8 +75,8 @@ func (f *FilterImpl) WithSelector(selector string) *FilterImpl { return f } -func (f *FilterImpl) WithTags(tags map[string]string) *FilterImpl { - f.FTags = tags +func (f *FilterImpl) WithRunnerTags(tags map[string]string) *FilterImpl { + f.FRunnerTags = tags return f } @@ -147,6 +149,6 @@ func (f FilterImpl) RunnerIds() []string { return f.FRunnerIds } -func (f FilterImpl) Tags() map[string]string { - return f.FTags +func (f FilterImpl) RunnerTags() map[string]string { + return f.FRunnerTags } diff --git a/pkg/repository/testworkflow/interface.go b/pkg/repository/testworkflow/interface.go index ed1efb9480d..e5b5b27dccf 100644 --- a/pkg/repository/testworkflow/interface.go +++ b/pkg/repository/testworkflow/interface.go @@ -27,7 +27,7 @@ type Filter interface { TextSearch() string Selector() string RunnerIds() []string - Tags() map[string]string + RunnerTags() map[string]string } //go:generate mockgen -destination=./mock_repository.go -package=testworkflow "github.com/kubeshop/testkube/pkg/repository/testworkflow" Repository diff --git a/pkg/repository/testworkflow/mongo.go b/pkg/repository/testworkflow/mongo.go index 878912556f5..222d8a83b57 100644 --- a/pkg/repository/testworkflow/mongo.go +++ b/pkg/repository/testworkflow/mongo.go @@ -365,8 +365,8 @@ func composeQueryAndOpts(filter Filter) (bson.M, *options.FindOptions) { } // this one needs wildard index or changing the model to {k:X v:Y} - if len(filter.Tags()) > 0 { - for k, v := range filter.Tags() { + if len(filter.RunnerTags()) > 0 { + for k, v := range filter.RunnerTags() { query["runningcontext.tags."+k] = v } }