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