snapshot of https://github.com/traggo/server.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
build / build (push) Failing after 3s
Some checks failed
build / build (push) Failing after 3s
This commit is contained in:
33
dashboard/entry/tagcheck.go
Normal file
33
dashboard/entry/tagcheck.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package entry
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/traggo/server/model"
|
||||
)
|
||||
|
||||
func tagsDuplicates(tags []model.DashboardTagFilter) error {
|
||||
existingTags := make(map[model.DashboardTagFilter]struct{})
|
||||
|
||||
for _, tag := range tags {
|
||||
if _, ok := existingTags[tag]; ok {
|
||||
tagType := "exclude"
|
||||
if tag.Include {
|
||||
tagType = "include"
|
||||
}
|
||||
|
||||
return fmt.Errorf("%s tags: tag '%s' is present multiple times", tagType, tag.Key+":"+tag.StringValue)
|
||||
} else {
|
||||
copyTag := tag
|
||||
copyTag.Include = !copyTag.Include
|
||||
|
||||
if _, ok := existingTags[copyTag]; ok {
|
||||
return fmt.Errorf("tag '%s' is present in both exclude tags and include tags", tag.Key+":"+tag.StringValue)
|
||||
}
|
||||
}
|
||||
|
||||
existingTags[tag] = struct{}{}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user