Files
karma/transform/links.go
Łukasz Mierzwa e239fd05fd Import code from internal repository (#1)
Import code from internal repository
2017-03-23 16:58:04 -07:00

22 lines
536 B
Go

package transform
import "github.com/asaskevich/govalidator"
// DetectLinks takes alert annotation dict and returns two dicts:
// first with regular annotations
// secondd with annotations where values are URLs
func DetectLinks(sourceAnnotations map[string]string) (map[string]string, map[string]string) {
links := make(map[string]string)
annotations := make(map[string]string)
for k, v := range sourceAnnotations {
if govalidator.IsURL(v) {
links[k] = v
} else {
annotations[k] = v
}
}
return annotations, links
}