fix reading toml for output and database

This commit is contained in:
genofire 2022-04-14 00:14:07 +02:00
parent 18c0362021
commit 773545643c
2 changed files with 6 additions and 14 deletions

View File

@ -23,16 +23,12 @@ func Connect(allConnection map[string]interface{}) (database.Connection, error)
log.WithField("database", dbType).Infof("no configuration found") log.WithField("database", dbType).Infof("no configuration found")
continue continue
} }
dbConfigs, ok := configForType.([]interface{}) dbConfigs, ok := configForType.([]map[string]interface{})
if !ok { 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 { for _, config := 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

@ -27,15 +27,11 @@ func Register(configuration map[string]interface{}) (output.Output, error) {
log.WithField("output", outputType).Infof("no configuration found") log.WithField("output", outputType).Infof("no configuration found")
continue continue
} }
outputConfigs, ok := configForOutput.([]interface{}) outputConfigs, ok := configForOutput.([]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: read format %T should be an []map[string]interface{}", outputType, configForOutput)
} }
for _, outputConfig := range outputConfigs { for _, config := 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 { if c, ok := config["enable"].(bool); ok && !c {
continue continue
} }