stackdriver: fix broken substring. also adds tests

(cherry picked from commit 68332c5951)
This commit is contained in:
Erik Sundell
2018-10-02 17:29:51 +02:00
committed by bergquist
parent 897cf51e75
commit dee26f3d2f
2 changed files with 18 additions and 2 deletions

View File

@@ -170,8 +170,11 @@ func reverse(s string) string {
}
func interpolateFilterWildcards(value string) string {
if strings.HasSuffix(value, "*") && strings.HasPrefix(value, "*") {
value = strings.Replace(value, "*", "", 1)
re := regexp.MustCompile("[*]")
matches := re.FindAllStringIndex(value, -1)
logger.Info("len", "len", len(matches))
if len(matches) == 2 && strings.HasSuffix(value, "*") && strings.HasPrefix(value, "*") {
value = strings.Replace(value, "*", "", -1)
value = fmt.Sprintf(`has_substring("%s")`, value)
} else if strings.HasPrefix(value, "*") {
value = strings.Replace(value, "*", "", 1)