Skip to content

Commit

Permalink
chore: rename tags in filter
Browse files Browse the repository at this point in the history
  • Loading branch information
exu committed Aug 9, 2024
1 parent b95db95 commit e582a1c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
14 changes: 8 additions & 6 deletions pkg/repository/testworkflow/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"github.com/kubeshop/testkube/pkg/api/v1/testkube"
)

var _ Filter = &FilterImpl{}

type FilterImpl struct {
FName string
FLastNDays int
Expand All @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion pkg/repository/testworkflow/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/repository/testworkflow/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit e582a1c

Please sign in to comment.