Fixed bug in decoder package

This commit is contained in:
Xavi Ramirez 2017-08-02 19:47:14 +00:00
parent 7a7716e824
commit 266d7d620d
2 changed files with 12 additions and 7 deletions

View file

@ -319,9 +319,14 @@ func ExtractKVMeta(kvlog map[string]interface{}) KVMeta {
tmp, ok = kvmeta["routes"]
if ok {
routes, ok := tmp.([]map[string]interface{})
routes, ok := tmp.([]interface{})
if ok {
kvRoutes = routes
for _, route := range routes {
rule, ok := route.(map[string]interface{})
if ok { // TODO: log error
kvRoutes = append(kvRoutes, rule)
}
}
}
}

View file

@ -551,7 +551,7 @@ func TestExtractKVMeta(t *testing.T) {
"team": "green",
"kv_version": "three",
"kv_language": "tree",
"routes": []map[string]interface{}{
"routes": []interface{}{
map[string]interface{}{
"type": "metrics",
"rule": "cool",
@ -590,7 +590,7 @@ func TestExtractKVMeta(t *testing.T) {
"team": "green",
"kv_version": "christmas",
"kv_language": "tree",
"routes": []map[string]interface{}{
"routes": []interface{}{
map[string]interface{}{
"type": "analytics",
"rule": "what's-this?",
@ -632,7 +632,7 @@ func TestExtractKVMeta(t *testing.T) {
"team": "slack",
"kv_version": "evergreen",
"kv_language": "markdown-ish",
"routes": []map[string]interface{}{
"routes": []interface{}{
map[string]interface{}{
"type": "notifications",
"rule": "did-you-know",
@ -678,7 +678,7 @@ func TestExtractKVMeta(t *testing.T) {
"team": "a-team",
"kv_version": "old",
"kv_language": "jive",
"routes": []map[string]interface{}{
"routes": []interface{}{
map[string]interface{}{
"type": "alerts",
"rule": "last-call",
@ -740,7 +740,7 @@ func TestExtractKVMeta(t *testing.T) {
"team": "diversity",
"kv_version": "kv-routes",
"kv_language": "understanding",
"routes": []map[string]interface{}{
"routes": []interface{}{
map[string]interface{}{
"type": "metrics",
"rule": "all-combos",