Merge pull request #8 from Clever/INFRA-2263-kvroutes-bugfix
decode: json decodes dimensions as array of interface
This commit is contained in:
commit
035cc7fd83
2 changed files with 16 additions and 7 deletions
|
|
@ -154,11 +154,20 @@ func getStringArray(json map[string]interface{}, key string) []string {
|
|||
return []string{}
|
||||
}
|
||||
|
||||
strArray, ok := val.([]string)
|
||||
iArray, ok := val.([]interface{})
|
||||
if !ok {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
strArray := []string{}
|
||||
for _, item := range iArray {
|
||||
s, ok := item.(string)
|
||||
if !ok {
|
||||
return []string{}
|
||||
}
|
||||
strArray = append(strArray, s)
|
||||
}
|
||||
|
||||
return strArray
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -562,13 +562,13 @@ func TestExtractKVMeta(t *testing.T) {
|
|||
"rule": "cool",
|
||||
"series": "1,1,2,3,5,8,13",
|
||||
"value_field": "value",
|
||||
"dimensions": []string{"app", "district"},
|
||||
"dimensions": []interface{}{"app", "district"},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"type": "metrics",
|
||||
"rule": "cool2",
|
||||
"series": "1,1,2,6,24,120,720,5040",
|
||||
"dimensions": []string{"app", "district"},
|
||||
"dimensions": []interface{}{"app", "district"},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -688,7 +688,7 @@ func TestExtractKVMeta(t *testing.T) {
|
|||
"type": "alerts",
|
||||
"rule": "last-call",
|
||||
"series": "doing-it-til-we-fall",
|
||||
"dimensions": []string{"who", "where"},
|
||||
"dimensions": []interface{}{"who", "where"},
|
||||
"stat_type": "guage",
|
||||
"value_field": "status",
|
||||
},
|
||||
|
|
@ -696,7 +696,7 @@ func TestExtractKVMeta(t *testing.T) {
|
|||
"type": "alerts",
|
||||
"rule": "watch-out-now",
|
||||
"series": "dem-gators-gonna-bite-ya",
|
||||
"dimensions": []string{"how-fresh", "how-clean"},
|
||||
"dimensions": []interface{}{"how-fresh", "how-clean"},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -750,7 +750,7 @@ func TestExtractKVMeta(t *testing.T) {
|
|||
"type": "metrics",
|
||||
"rule": "all-combos",
|
||||
"series": "1,1,2,6,24,120,720,5040",
|
||||
"dimensions": []string{"fact", "orial"},
|
||||
"dimensions": []interface{}{"fact", "orial"},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"type": "analytics",
|
||||
|
|
@ -767,7 +767,7 @@ func TestExtractKVMeta(t *testing.T) {
|
|||
"type": "alerts",
|
||||
"rule": "last-call",
|
||||
"series": "doing-it-til-we-fall",
|
||||
"dimensions": []string{"who", "where"},
|
||||
"dimensions": []interface{}{"who", "where"},
|
||||
"stat_type": "guage",
|
||||
"value_field": "status",
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue