[BUGFIX] convert config in steps

This commit is contained in:
Martin Geno 2018-01-15 01:01:32 +01:00
parent 63b1d994a6
commit 94c9dd2f6c
No known key found for this signature in database
GPG Key ID: F0D39A37E925E941
4 changed files with 25 additions and 17 deletions

View File

@ -22,12 +22,16 @@ func Connect(allConnection map[string]interface{}) (database.Connection, error)
log.Printf("the output type '%s' has no configuration", dbType) log.Printf("the output type '%s' has no configuration", dbType)
continue continue
} }
dbConfigs, ok := configForType.([]map[string]interface{}) dbConfigs, ok := configForType.([]interface{})
if !ok { if !ok {
return nil, fmt.Errorf("the output type '%s' has the wrong format", dbType) return nil, fmt.Errorf("the database type '%s' has the wrong format", dbType)
} }
for _, config := range dbConfigs { for _, dbConfig := range dbConfigs {
config, ok := dbConfig.(map[string]interface{})
if !ok {
return nil, fmt.Errorf("the database type '%s' has the wrong format", dbType)
}
if c, ok := config["enable"].(bool); ok && !c { if c, ok := config["enable"].(bool); ok && !c {
continue continue
} }

View File

@ -38,14 +38,14 @@ func TestStart(t *testing.T) {
}, },
}, },
"b": nil, "b": nil,
"c": []map[string]interface{}{ "c": []interface{}{
{ map[string]interface{}{
"path": "c1", "path": "c1",
}, },
}, },
// fetch continue command in Connect // fetch continue command in Connect
"d": []map[string]interface{}{ "d": []interface{}{
{ map[string]interface{}{
"path": "d0", "path": "d0",
}, },
}, },

View File

@ -25,11 +25,15 @@ func Register(configuration map[string]interface{}) (output.Output, error) {
log.Printf("the output type '%s' has no configuration\n", outputType) log.Printf("the output type '%s' has no configuration\n", outputType)
continue continue
} }
outputConfigs, ok := configForOutput.([]map[string]interface{}) outputConfigs, ok := configForOutput.([]interface{})
if !ok {
return nil, fmt.Errorf("the output type '%s' has the wrong format", outputType)
}
for _, outputConfig := range outputConfigs {
config, ok := outputConfig.(map[string]interface{})
if !ok { if !ok {
return nil, fmt.Errorf("the output type '%s' has the wrong format", outputType) return nil, fmt.Errorf("the output type '%s' has the wrong format", outputType)
} }
for _, config := range outputConfigs {
if c, ok := config["enable"].(bool); ok && !c { if c, ok := config["enable"].(bool); ok && !c {
continue continue
} }

View File

@ -49,29 +49,29 @@ func TestStart(t *testing.T) {
return nil, errors.New("blub") return nil, errors.New("blub")
}) })
allOutput, err := Register(map[string]interface{}{ allOutput, err := Register(map[string]interface{}{
"a": []map[string]interface{}{ "a": []interface{}{
{ map[string]interface{}{
"enable": false, "enable": false,
"path": "a1", "path": "a1",
}, },
{ map[string]interface{}{
"path": "a2", "path": "a2",
}, },
{ map[string]interface{}{
"enable": true, "enable": true,
"path": "a3", "path": "a3",
}, },
}, },
"b": nil, "b": nil,
"c": []map[string]interface{}{ "c": []interface{}{
{ map[string]interface{}{
"path": "c1", "path": "c1",
"filter": map[string]interface{}{}, "filter": map[string]interface{}{},
}, },
}, },
// fetch continue command in Connect // fetch continue command in Connect
"d": []map[string]interface{}{ "d": []interface{}{
{ map[string]interface{}{
"path": "d0", "path": "d0",
}, },
}, },