diff --git a/database/all/connection.go b/database/all/connection.go index 9d18706..fcdc3a2 100644 --- a/database/all/connection.go +++ b/database/all/connection.go @@ -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 } diff --git a/database/all/internel_test.go b/database/all/internel_test.go index ea9264e..21e871b 100644 --- a/database/all/internel_test.go +++ b/database/all/internel_test.go @@ -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", }, }, diff --git a/output/all/output.go b/output/all/output.go index 4861659..ae64c08 100644 --- a/output/all/output.go +++ b/output/all/output.go @@ -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 } diff --git a/output/all/output_test.go b/output/all/output_test.go index 0373df4..75513bc 100644 --- a/output/all/output_test.go +++ b/output/all/output_test.go @@ -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", }, },