2021-10-20 20:26:37 +00:00
|
|
|
package store
|
2017-06-30 11:21:01 +02:00
|
|
|
|
|
|
|
// Some helper functions
|
|
|
|
import (
|
2017-07-10 14:19:36 +01:00
|
|
|
"strconv"
|
2017-06-30 11:21:01 +02:00
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2021-03-22 17:35:20 +01:00
|
|
|
// ContainsCi is like `strings.Contains` but case insensitive
|
2017-06-30 11:21:01 +02:00
|
|
|
func ContainsCi(s, substr string) bool {
|
|
|
|
return strings.Contains(
|
|
|
|
strings.ToLower(s),
|
|
|
|
strings.ToLower(substr),
|
|
|
|
)
|
|
|
|
}
|
2017-06-30 12:05:46 +02:00
|
|
|
|
2021-03-22 17:35:20 +01:00
|
|
|
// SerializeReasons asserts the bgp communitiy parts are
|
|
|
|
// actually strings, because there are no such things as
|
|
|
|
// integers as keys in json.
|
|
|
|
// Serialization of this is undefined behaviour, so we
|
|
|
|
// keep these interallybut provide a string as a key for
|
|
|
|
// serialization
|
2017-07-10 14:19:36 +01:00
|
|
|
func SerializeReasons(reasons map[int]string) map[string]string {
|
|
|
|
res := make(map[string]string)
|
|
|
|
for id, reason := range reasons {
|
|
|
|
res[strconv.Itoa(id)] = reason
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
}
|