From 773545643c670def2cfa41acef1bf303a8f4beee Mon Sep 17 00:00:00 2001 From: genofire Date: Thu, 14 Apr 2022 00:14:07 +0200 Subject: [PATCH] fix reading toml for output and database --- database/all/connection.go | 10 +++------- output/all/output.go | 10 +++------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/database/all/connection.go b/database/all/connection.go index e85bfaa..23fd14b 100644 --- a/database/all/connection.go +++ b/database/all/connection.go @@ -23,16 +23,12 @@ func Connect(allConnection map[string]interface{}) (database.Connection, error) log.WithField("database", dbType).Infof("no configuration found") continue } - dbConfigs, ok := configForType.([]interface{}) + dbConfigs, ok := configForType.([]map[string]interface{}) if !ok { - return nil, fmt.Errorf("the database type '%s' has the wrong format", dbType) + return nil, fmt.Errorf("the database type '%s' has the wrong format: read format %T should be an []map[string]interface{}", dbType, configForType) } - 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) - } + for _, config := range dbConfigs { if c, ok := config["enable"].(bool); ok && !c { continue } diff --git a/output/all/output.go b/output/all/output.go index 14d1cc1..73c1383 100644 --- a/output/all/output.go +++ b/output/all/output.go @@ -27,15 +27,11 @@ func Register(configuration map[string]interface{}) (output.Output, error) { log.WithField("output", outputType).Infof("no configuration found") continue } - outputConfigs, ok := configForOutput.([]interface{}) + outputConfigs, ok := configForOutput.([]map[string]interface{}) 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: read format %T should be an []map[string]interface{}", outputType, configForOutput) } - 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) - } + for _, config := range outputConfigs { if c, ok := config["enable"].(bool); ok && !c { continue }