[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)
continue
}
dbConfigs, ok := configForType.([]map[string]interface{})
dbConfigs, ok := configForType.([]interface{})
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 {
continue
}

View File

@ -38,14 +38,14 @@ func TestStart(t *testing.T) {
},
},
"b": nil,
"c": []map[string]interface{}{
{
"c": []interface{}{
map[string]interface{}{
"path": "c1",
},
},
// fetch continue command in Connect
"d": []map[string]interface{}{
{
"d": []interface{}{
map[string]interface{}{
"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)
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 _, config := range outputConfigs {
for _, outputConfig := range outputConfigs {
config, ok := outputConfig.(map[string]interface{})
if !ok {
return nil, fmt.Errorf("the output type '%s' has the wrong format", outputType)
}
if c, ok := config["enable"].(bool); ok && !c {
continue
}

View File

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