mirror of
https://github.com/prymitive/karma
synced 2026-05-05 03:16:51 +00:00
Internal packages are supported by Go 1.5+, any package in /internal/ dir is only importable from the same repo. This will cleanup main dir a bit and provide better namespace for unsee subpackages
25 lines
727 B
Go
25 lines
727 B
Go
package transform
|
|
|
|
import (
|
|
"github.com/cloudflare/unsee/internal/filters"
|
|
"github.com/cloudflare/unsee/internal/models"
|
|
)
|
|
|
|
// BuildAutocomplete takes an alert object and generates list of autocomplete
|
|
// strings for it
|
|
func BuildAutocomplete(alerts []models.Alert) []models.Autocomplete {
|
|
acHints := map[string]models.Autocomplete{}
|
|
for _, filterConfig := range filters.AllFilters {
|
|
if filterConfig.Autocomplete != nil {
|
|
for _, hint := range filterConfig.Autocomplete(filterConfig.Label, filterConfig.SupportedOperators, alerts) {
|
|
acHints[hint.Value] = hint
|
|
}
|
|
}
|
|
}
|
|
acHintsSlice := []models.Autocomplete{}
|
|
for _, hint := range acHints {
|
|
acHintsSlice = append(acHintsSlice, hint)
|
|
}
|
|
return acHintsSlice
|
|
}
|